2 gopherRoot = "/tmp/gopher";
3 gopherHost = "gopherd";
4 gopherClient = "client";
5 fileContent = "Hello Gopher!\n";
8 import ./make-test-python.nix ({...}: {
12 systemd.services.spacecookie = {
14 mkdir -p ${gopherRoot}/directory
15 printf "%s" "${fileContent}" > ${gopherRoot}/${fileName}
19 services.spacecookie = {
24 hostname = gopherHost;
35 # with daemon type notify, the unit being started
36 # should also mean the port is open
37 ${gopherHost}.wait_for_unit("spacecookie.service")
38 ${gopherClient}.wait_for_unit("network.target")
40 fileResponse = ${gopherClient}.succeed("curl -f -s gopher://${gopherHost}/0/${fileName}")
42 # the file response should return our created file exactly
43 if not (fileResponse == "${builtins.replaceStrings [ "\n" ] [ "\\n" ] fileContent}"):
44 raise Exception("Unexpected file response")
46 # sanity check on the directory listing: we serve a directory and a file
47 # via gopher, so the directory listing should have exactly two entries,
48 # one with gopher file type 0 (file) and one with file type 1 (directory).
49 dirResponse = ${gopherClient}.succeed("curl -f -s gopher://${gopherHost}")
50 dirEntries = [l[0] for l in dirResponse.split("\n") if len(l) > 0]
53 if not (["0", "1"] == dirEntries):
54 raise Exception("Unexpected directory response")