about summary refs log tree commit diff
path: root/nixos/tests/gitea.nix
diff options
context:
space:
mode:
authorAaron Andersen <aaron@fosslib.net>2018-11-05 21:06:30 -0500
committerAaron Andersen <aaron@fosslib.net>2018-11-08 17:31:05 -0500
commit0dde47a58acdd3cff855796bbd899c90c7fb25b5 (patch)
tree967181af9ce29381ced2a57d52f276070f02d1a9 /nixos/tests/gitea.nix
parent3ed52c78047bcc4b74d34e0cee179bb708aebdc0 (diff)
nixos/gitea: add a nixos test to ensure the initial database migration succeeds so the application can start
Diffstat (limited to 'nixos/tests/gitea.nix')
-rw-r--r--nixos/tests/gitea.nix74
1 files changed, 74 insertions, 0 deletions
diff --git a/nixos/tests/gitea.nix b/nixos/tests/gitea.nix
new file mode 100644
index 0000000000000..7ffe05ef3f1fb
--- /dev/null
+++ b/nixos/tests/gitea.nix
@@ -0,0 +1,74 @@
+{ system ? builtins.currentSystem }:
+
+with import ../lib/testing.nix { inherit system; };
+with pkgs.lib;
+
+{
+  mysql = makeTest {
+    name = "gitea-mysql";
+    meta.maintainers = [ maintainers.aanderse ];
+
+    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.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;
+      };
+
+    testScript = ''
+      startAll;
+
+      $machine->waitForUnit('gitea.service');
+      $machine->waitForOpenPort('3000');
+      $machine->succeed("curl --fail http://localhost:3000/");
+    '';
+  };
+}