nixos/gitea: simplify test

This reduces the length of the gitea-test by creating a single
`makeGiteaTest` function which creates the configuration for a testcase
with a given database driver.
This commit is contained in:
Maximilian Bosch 2019-12-06 18:59:37 +01:00
parent 34084d471e
commit 8264d7ed4c
No known key found for this signature in database
GPG Key ID: 091DBF4D1FC46B8E

View File

@ -6,54 +6,18 @@
with import ../lib/testing-python.nix { inherit system pkgs; }; with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib; with pkgs.lib;
{ let
mysql = makeTest { supportedDbTypes = [ "mysql" "postgres" "sqlite3" ];
name = "gitea-mysql"; makeGiteaTest = type: nameValuePair type (makeTest {
meta.maintainers = with maintainers; [ aanderse kolaente ]; name = "gitea-${type}";
meta.maintainers = with maintainers; [ aanderse kolaente ma27 ];
machine = machine = { config, pkgs, ... }: {
{ config, pkgs, ... }: services.gitea = {
{ services.gitea.enable = true; enable = true;
services.gitea.database.type = "mysql"; database = { inherit type; };
}; disableRegistration = true;
testScript = ''
start_all()
machine.wait_for_unit("gitea.service")
machine.wait_for_open_port(3000)
machine.succeed("curl --fail http://localhost:3000/")
'';
};
postgres = makeTest {
name = "gitea-postgres";
meta.maintainers = [ maintainers.aanderse ];
machine =
{ config, pkgs, ... }:
{ services.gitea.enable = true;
services.gitea.database.type = "postgres";
};
testScript = ''
start_all()
machine.wait_for_unit("gitea.service")
machine.wait_for_open_port(3000)
machine.succeed("curl --fail http://localhost:3000/")
'';
};
sqlite = makeTest {
name = "gitea-sqlite";
meta.maintainers = [ maintainers.aanderse ];
machine =
{ config, pkgs, ... }:
{ services.gitea.enable = true;
services.gitea.disableRegistration = true;
}; };
};
testScript = '' testScript = ''
start_all() start_all()
@ -65,5 +29,7 @@ with pkgs.lib;
"curl --fail http://localhost:3000/user/sign_up | grep 'Registration is disabled. Please contact your site administrator.'" "curl --fail http://localhost:3000/user/sign_up | grep 'Registration is disabled. Please contact your site administrator.'"
) )
''; '';
}; });
} in
listToAttrs (map makeGiteaTest supportedDbTypes)