about summary refs log tree commit diff
path: root/nixos/tests/tandoor-recipes.nix
blob: 54456238fe634197b0ce09046c628673c9c05306 (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
import ./make-test-python.nix ({ lib, ... }: {
  name = "tandoor-recipes";
  meta.maintainers = with lib.maintainers; [ ambroisie ];

  nodes.machine = { pkgs, ... }: {
    # Setup using Postgres
    services.tandoor-recipes = {
      enable = true;

      extraConfig = {
        DB_ENGINE = "django.db.backends.postgresql";
        POSTGRES_HOST = "/run/postgresql";
        POSTGRES_USER = "tandoor_recipes";
        POSTGRES_DB = "tandoor_recipes";
      };
    };

    services.postgresql = {
      enable = true;
      ensureDatabases = [ "tandoor_recipes" ];
      ensureUsers = [
        {
          name = "tandoor_recipes";
          ensurePermissions."DATABASE tandoor_recipes" = "ALL PRIVILEGES";
        }
      ];
    };

    systemd.services = {
      tandoor-recipes = {
        after = [ "postgresql.service" ];
      };
    };
  };

  testScript = ''
    machine.wait_for_unit("tandoor-recipes.service")

    with subtest("Web interface gets ready"):
        # Wait until server accepts connections
        machine.wait_until_succeeds("curl -fs localhost:8080")
  '';
})