at 25.11-pre 1.1 kB view raw
1import ../make-test-python.nix ( 2 { pkgs, ... }: 3 let 4 testdir = pkgs.writeTextDir "www/app.psgi" '' 5 my $app = sub { 6 return [ 7 "200", 8 [ "Content-Type" => "text/plain" ], 9 [ "Hello, Perl on Unit!" ], 10 ]; 11 }; 12 ''; 13 14 in 15 { 16 name = "unit-perl-test"; 17 meta.maintainers = with pkgs.lib.maintainers; [ sgo ]; 18 19 nodes.machine = 20 { 21 config, 22 lib, 23 pkgs, 24 ... 25 }: 26 { 27 services.unit = { 28 enable = true; 29 config = pkgs.lib.strings.toJSON { 30 listeners."*:8080".application = "perl"; 31 applications.perl = { 32 type = "perl"; 33 script = "${testdir}/www/app.psgi"; 34 }; 35 }; 36 }; 37 }; 38 testScript = '' 39 machine.wait_for_unit("unit.service") 40 machine.wait_for_open_port(8080) 41 42 response = machine.succeed("curl -f -vvv -s http://127.0.0.1:8080/") 43 assert "Hello, Perl on Unit!" in response, "Hello world" 44 ''; 45 } 46)