about summary refs log tree commit diff
path: root/nixpkgs/nixos/tests/gitea.nix
blob: cccf8c7cd44fed30cf103d7a75393f939d2a691a (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
75
76
77
78
79
{ system ? builtins.currentSystem,
  config ? {},
  pkgs ? import ../.. { inherit system config; }
}:

with import ../lib/testing.nix { inherit system pkgs; };
with pkgs.lib;

{
  mysql = makeTest {
    name = "gitea-mysql";
    meta.maintainers = with maintainers; [ aanderse kolaente ];

    machine =
      { config, pkgs, ... }:
      { services.mysql.enable = true;
        services.mysql.package = pkgs.mariadb;
        services.mysql.ensureDatabases = [ "gitea" ];
        services.mysql.ensureUsers = [
          { name = "gitea";
            ensurePermissions = { "gitea.*" = "ALL PRIVILEGES"; };
          }
        ];

        services.gitea.enable = true;
        services.gitea.database.type = "mysql";
        services.gitea.database.socket = "/run/mysqld/mysqld.sock";
      };

    testScript = ''
      startAll;

      $machine->waitForUnit('gitea.service');
      $machine->waitForOpenPort('3000');
      $machine->succeed("curl --fail http://localhost:3000/");
    '';
  };

  postgres = makeTest {
    name = "gitea-postgres";
    meta.maintainers = [ maintainers.aanderse ];

    machine =
      { config, pkgs, ... }:
      {
        services.gitea.enable = true;
        services.gitea.database.type = "postgres";
        services.gitea.database.passwordFile = pkgs.writeText "db-password" "secret";
      };

    testScript = ''
      startAll;

      $machine->waitForUnit('gitea.service');
      $machine->waitForOpenPort('3000');
      $machine->succeed("curl --fail http://localhost:3000/");
    '';
  };

  sqlite = makeTest {
    name = "gitea-sqlite";
    meta.maintainers = [ maintainers.aanderse ];

    machine =
      { config, pkgs, ... }:
      { services.gitea.enable = true;
        services.gitea.disableRegistration = true;
      };

    testScript = ''
      startAll;

      $machine->waitForUnit('gitea.service');
      $machine->waitForOpenPort('3000');
      $machine->succeed("curl --fail http://localhost:3000/");
      $machine->succeed("curl --fail http://localhost:3000/user/sign_up | grep 'Registration is disabled. Please contact your site administrator.'");
    '';
  };
}