summaryrefslogtreecommitdiffstats
path: root/nixos/tests/szurubooru.nix
blob: a9a4ede9950b9b58581572610e56f46e02dbd769 (plain)
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
import ./make-test-python.nix (
  { lib, pkgs, ... }:
  {
    name = "szurubooru";
    meta.maintainers = with lib.maintainers; [ ratcornu ];

    nodes.machine =
      let
        dbpass = "changeme";
      in

      { config, ... }:
      {
        services.postgresql = {
          enable = true;
          initialScript = pkgs.writeText "init.sql" ''
            CREATE USER ${config.services.szurubooru.database.user} WITH PASSWORD '${dbpass}';
            CREATE DATABASE ${config.services.szurubooru.database.name} WITH OWNER ${config.services.szurubooru.database.user};
          '';
        };

        services.szurubooru = {
          enable = true;

          dataDir = "/var/lib/szurubooru";

          server = {
            port = 6666;
            host = "127.0.0.1";
            settings = {
              domain = "http://127.0.0.1";
              secretFile = pkgs.writeText "secret" "secret";
              debug = 1;
            };
          };

          database = {
            host = "localhost";
            port = 5432;
            name = "szurubooru";
            user = "szurubooru";
            passwordFile = pkgs.writeText "pass" "${dbpass}";
          };
        };
      };

    testScript = ''
      machine.wait_for_unit("szurubooru.service")
      machine.wait_for_open_port(6666)
      machine.succeed('curl -H "Content-Type: application/json" -H "Accept: application/json" --fail http://127.0.0.1:6666/info')
    '';
  }
)