1import ./make-test.nix ({ pkgs, lib, ... }:
2
3{
4 name = "atd";
5 meta = with pkgs.stdenv.lib.maintainers; {
6 maintainers = [ bjornfor ];
7 };
8
9 machine =
10 { config, pkgs, ... }:
11 { services.atd.enable = true;
12 users.extraUsers.alice = { isNormalUser = true; };
13 };
14
15 # "at" has a resolution of 1 minute
16 testScript = ''
17 startAll;
18
19 $machine->fail("test -f ~root/at-1");
20 $machine->fail("test -f ~root/batch-1");
21 $machine->fail("test -f ~alice/at-1");
22 $machine->fail("test -f ~alice/batch-1");
23
24 $machine->succeed("echo 'touch ~root/at-1' | at now+1min");
25 $machine->succeed("echo 'touch ~root/batch-1' | batch");
26 $machine->succeed("su - alice -c \"echo 'touch at-1' | at now+1min\"");
27 $machine->succeed("su - alice -c \"echo 'touch batch-1' | batch\"");
28
29 $machine->succeed("sleep 1.5m");
30
31 $machine->succeed("test -f ~root/at-1");
32 $machine->succeed("test -f ~root/batch-1");
33 $machine->succeed("test -f ~alice/at-1");
34 $machine->succeed("test -f ~alice/batch-1");
35 '';
36})