about summary refs log tree commit diff
path: root/nixos/tests/vikunja.nix
blob: 4e2bf166a7b6cd74fbc7a9aea3eab7ec369cdd6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import ./make-test-python.nix ({ pkgs, lib, ... }: {
  name = "vikunja";

  meta.maintainers = with lib.maintainers; [ leona ];

  nodes = {
    vikunjaSqlite = { ... }: {
      services.vikunja = {
        enable = true;
        database = {
          type = "sqlite";
        };
        frontendScheme = "http";
        frontendHostname = "localhost";
      };
      services.nginx = {
        enable = true;
        virtualHosts."http://localhost" = {
          locations."/".proxyPass = "http://localhost:3456";
        };
      };
    };
    vikunjaPostgresql = { pkgs, ... }: {
      services.vikunja = {
        enable = true;
        database = {
          type = "postgres";
          user = "vikunja";
          database = "vikunja";
          host = "/run/postgresql";
        };
        frontendScheme = "http";
        frontendHostname = "localhost";
        port = 9090;
      };
      services.postgresql = {
        enable = true;
        ensureDatabases = [ "vikunja" ];
        ensureUsers = [
          { name = "vikunja";
            ensureDBOwnership = true;
          }
        ];
      };
      services.nginx = {
        enable = true;
        virtualHosts."http://localhost" = {
          locations."/".proxyPass = "http://localhost:9090";
        };
      };
    };
  };

  testScript =
    ''
      vikunjaSqlite.wait_for_unit("vikunja.service")
      vikunjaSqlite.wait_for_open_port(3456)
      vikunjaSqlite.succeed("curl --fail http://localhost:3456/api/v1/info")

      vikunjaSqlite.wait_for_unit("nginx.service")
      vikunjaSqlite.wait_for_open_port(80)
      vikunjaSqlite.succeed("curl --fail http://localhost/api/v1/info")
      vikunjaSqlite.succeed("curl --fail http://localhost")

      vikunjaPostgresql.wait_for_unit("vikunja.service")
      vikunjaPostgresql.wait_for_open_port(9090)
      vikunjaPostgresql.succeed("curl --fail http://localhost:9090/api/v1/info")

      vikunjaPostgresql.wait_for_unit("nginx.service")
      vikunjaPostgresql.wait_for_open_port(80)
      vikunjaPostgresql.succeed("curl --fail http://localhost/api/v1/info")
      vikunjaPostgresql.succeed("curl --fail http://localhost")
    '';
})