diff options
Diffstat (limited to 'nix/test-socket-usage.nix')
-rw-r--r-- | nix/test-socket-usage.nix | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/nix/test-socket-usage.nix b/nix/test-socket-usage.nix index 25aa5fc..409dd68 100644 --- a/nix/test-socket-usage.nix +++ b/nix/test-socket-usage.nix @@ -1,3 +1,8 @@ +let + # Normally the max-idle time would probably be a little longer than this, but + # I don't want to drag out this test for 10 minutes. + max-idle-secs = 20; +in { name = "socket-usage"; @@ -16,6 +21,8 @@ } ]; + max-idle-time = "${toString max-idle-secs}s"; + # The secret to be used when authenticating event's signature. secret-path = toString (pkgs.writeText "secret.txt" "mysecret"); }; @@ -69,6 +76,8 @@ }; testScript = '' + import time + machine.start() with subtest("Proper (lazy) socket activation"): @@ -87,6 +96,13 @@ exit_code, _ = machine.systemctl("is-active webhook-listener.service --quiet") assert exit_code == 0, "Event should be active" + with subtest("Service should exit after idle time"): + # Give it a little buffer to avoid false negatives. + time.sleep(${toString max-idle-secs} + 5) + + exit_code, _ = machine.systemctl("is-active webhook-listener.service --quiet") + assert exit_code == 3, "Event should be inactive" + # TODO: Send an invalid request (subtest). ''; } |