nixos/tests: add unit-php test

This commit is contained in:
Izorkin 2020-04-16 23:08:00 +03:00
parent dc0260f7da
commit ca2145bdfc
3 changed files with 51 additions and 1 deletions

View File

@ -321,6 +321,7 @@ in
trickster = handleTest ./trickster.nix {};
tuptime = handleTest ./tuptime.nix {};
udisks2 = handleTest ./udisks2.nix {};
unit-php = handleTest ./web-servers/unit-php.nix {};
upnp = handleTest ./upnp.nix {};
uwsgi = handleTest ./uwsgi.nix {};
vault = handleTest ./vault.nix {};

View File

@ -0,0 +1,47 @@
import ../make-test-python.nix ({pkgs, ...}:
let
testdir = pkgs.writeTextDir "www/info.php" "<?php phpinfo();";
in {
name = "unit-php-test";
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ izorkin ];
machine = { config, lib, pkgs, ... }: {
services.unit = {
enable = true;
config = ''
{
"listeners": {
"*:9074": {
"application": "php_74"
}
},
"applications": {
"php_74": {
"type": "php 7.4",
"processes": 1,
"user": "testuser",
"group": "testgroup",
"root": "${testdir}/www",
"index": "info.php"
}
}
}
'';
};
users = {
users.testuser = {
isNormalUser = false;
uid = 1074;
group = "testgroup";
};
groups.testgroup = {
gid= 1074;
};
};
};
testScript = ''
machine.wait_for_unit("unit.service")
assert "PHP Version ${pkgs.php74.version}" in machine.succeed("curl -vvv -s http://127.0.0.1:9074/")
'';
})

View File

@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, which
{ stdenv, fetchFromGitHub, nixosTests, which
, withPython2 ? false, python2
, withPython3 ? true, python3, ncurses
, withPHP72 ? false, php72
@ -81,6 +81,8 @@ in stdenv.mkDerivation rec {
${optionalString withRuby_2_7 "./configure ruby --module=ruby27 --ruby=${ruby_2_7}/bin/ruby"}
'';
passthru.tests.unit-php = nixosTests.unit-php;
meta = {
description = "Dynamic web and application server, designed to run applications in multiple languages.";
homepage = "https://unit.nginx.org/";