summary refs log tree commit diff
path: root/nixos/tests/codimd.nix
blob: 562f6f24f999c9cab8766fac7ef39de616b52b52 (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
import ./make-test.nix ({ pkgs, lib, ... }:
{
  name = "codimd";

  meta = with lib.maintainers; {
    maintainers = [ willibutz ];
  };

  nodes = {
    codimdSqlite = { ... }: {
      services = {
        codimd = {
          enable = true;
          configuration.dbURL = "sqlite:///var/lib/codimd/codimd.db";
        };
      };
    };

    codimdPostgres = { ... }: {
      systemd.services.codimd.after = [ "postgresql.service" ];
      services = {
        codimd = {
          enable = true;
          configuration.dbURL = "postgres://codimd:snakeoilpassword@localhost:5432/codimddb";
        };
        postgresql = {
          enable = true;
          initialScript = pkgs.writeText "pg-init-script.sql" ''
            CREATE ROLE codimd LOGIN PASSWORD 'snakeoilpassword';
            CREATE DATABASE codimddb OWNER codimd;
          '';
        };
      };
    };
  };

  testScript = ''
    startAll();

    subtest "CodiMD sqlite", sub {
      $codimdSqlite->waitForUnit("codimd.service");
      $codimdSqlite->waitForOpenPort(3000);
      $codimdSqlite->waitUntilSucceeds("curl -sSf http://localhost:3000/new");
    };

    subtest "CodiMD postgres", sub {
      $codimdPostgres->waitForUnit("postgresql.service");
      $codimdPostgres->waitForUnit("codimd.service");
      $codimdPostgres->waitForOpenPort(5432);
      $codimdPostgres->waitForOpenPort(3000);
      $codimdPostgres->waitUntilSucceeds("curl -sSf http://localhost:3000/new");
    };
  '';
})