nixos-gitit/test.nix

58 lines
1.3 KiB
Nix
Raw Normal View History

2021-12-31 13:35:22 +02:00
{ modules }:
{
machine = { config, pkgs, lib, ... }:
{
imports = modules;
environment.systemPackages = [
pkgs.curl
];
services.gitit = {
enable = true;
port = 4001;
wiki-title = "Test Wiki";
address = "127.0.0.1";
};
networking.extraHosts = ''
127.0.0.1 wiki.local
'';
services.nginx = {
enable = true;
virtualHosts."wiki.local" = {
locations."/" = {
proxyPass = "http://127.0.0.1:4001";
};
};
};
};
testScript =
let username = "foo";
password = "foobar123";
form = "'username=${username}&email=&full_name_1=&password=${password}&password2=${password}&destination=%2F_index&register=Register'";
in
''
start_all()
machine.wait_for_unit("gitit.service")
machine.wait_for_open_port(4001)
if "Test Wiki" not in machine.succeed("curl -sS http://localhost:4001"):
raise Exception("Title not set properly")
machine.succeed("curl --data-raw ${form} 'http://localhost:4001/_register?destination=%2F_index'")
machine.wait_for_unit("nginx.service")
machine.wait_for_open_port(80)
if "Test Wiki" not in machine.succeed("curl -sS http://wiki.local:80"):
raise Exception("Wiki not available through nginx")
'';
}