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