Skip to content

Commit

Permalink
unit: add nixos tests for perl
Browse files Browse the repository at this point in the history
  • Loading branch information
stigtsp committed Sep 8, 2024
1 parent 762d2c1 commit 67ecdcb
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ in {
unbound = handleTest ./unbound.nix {};
unifi = handleTest ./unifi.nix {};
unit-php = handleTest ./web-servers/unit-php.nix {};
unit-perl = handleTest ./web-servers/unit-perl.nix {};
upnp.iptables = handleTest ./upnp.nix { useNftables = false; };
upnp.nftables = handleTest ./upnp.nix { useNftables = true; };
uptermd = handleTest ./uptermd.nix {};
Expand Down
46 changes: 46 additions & 0 deletions nixos/tests/web-servers/unit-perl.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import ../make-test-python.nix (
{ pkgs, ... }:
let
testdir = pkgs.writeTextDir "www/app.psgi" ''
my $app = sub {
return [
"200",
[ "Content-Type" => "text/plain" ],
[ "Hello, Perl on Unit!" ],
];
};
'';

in
{
name = "unit-perl-test";
meta.maintainers = with pkgs.lib.maintainers; [ sgo ];

nodes.machine =
{
config,
lib,
pkgs,
...
}:
{
services.unit = {
enable = true;
config = pkgs.lib.strings.toJSON {
listeners."*:8080".application = "perl";
applications.perl = {
type = "perl";
script = "${testdir}/www/app.psgi";
};
};
};
};
testScript = ''
machine.wait_for_unit("unit.service")
machine.wait_for_open_port(8080)
response = machine.succeed("curl -f -vvv -s http://127.0.0.1:8080/")
assert "Hello, Perl on Unit!" in response, "Hello world"
'';
}
)
5 changes: 4 additions & 1 deletion pkgs/servers/http/unit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ in stdenv.mkDerivation rec {
${optionalString withRuby_3_2 "./configure ruby --module=ruby32 --ruby=${ruby_3_2}/bin/ruby"}
'';

passthru.tests.unit-php = nixosTests.unit-php;
passthru.tests = {
unit-perl = nixosTests.unit-perl;
unit-php = nixosTests.unit-php;
};

meta = with lib; {
description = "Dynamic web and application server, designed to run applications in multiple languages";
Expand Down

0 comments on commit 67ecdcb

Please sign in to comment.