summary refs log tree commit diff
path: root/nixos/tests/gitea.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2019-12-06 18:59:37 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2019-12-06 18:59:37 +0100
commit8264d7ed4c6138629f814a6b60701bb11ce836f6 (patch)
tree18811f716360f160aa238bcefd8bf7efc65626d7 /nixos/tests/gitea.nix
parent34084d471e24205c211aa8384e0316680bfc1feb (diff)
downloadnixpkgs-8264d7ed4c6138629f814a6b60701bb11ce836f6.tar
nixpkgs-8264d7ed4c6138629f814a6b60701bb11ce836f6.tar.gz
nixpkgs-8264d7ed4c6138629f814a6b60701bb11ce836f6.tar.bz2
nixpkgs-8264d7ed4c6138629f814a6b60701bb11ce836f6.tar.lz
nixpkgs-8264d7ed4c6138629f814a6b60701bb11ce836f6.tar.xz
nixpkgs-8264d7ed4c6138629f814a6b60701bb11ce836f6.tar.zst
nixpkgs-8264d7ed4c6138629f814a6b60701bb11ce836f6.zip
nixos/gitea: simplify test
This reduces the length of the gitea-test by creating a single
`makeGiteaTest` function which creates the configuration for a testcase
with a given database driver.
Diffstat (limited to 'nixos/tests/gitea.nix')
-rw-r--r--nixos/tests/gitea.nix64
1 files changed, 15 insertions, 49 deletions
diff --git a/nixos/tests/gitea.nix b/nixos/tests/gitea.nix
index ffbc07cfbb2..dc3347228e3 100644
--- a/nixos/tests/gitea.nix
+++ b/nixos/tests/gitea.nix
@@ -6,54 +6,18 @@
 with import ../lib/testing-python.nix { inherit system pkgs; };
 with pkgs.lib;
 
-{
-  mysql = makeTest {
-    name = "gitea-mysql";
-    meta.maintainers = with maintainers; [ aanderse kolaente ];
-
-    machine =
-      { config, pkgs, ... }:
-      { services.gitea.enable = true;
-        services.gitea.database.type = "mysql";
-      };
-
-    testScript = ''
-      start_all()
-
-      machine.wait_for_unit("gitea.service")
-      machine.wait_for_open_port(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";
-      };
-
-    testScript = ''
-      start_all()
-
-      machine.wait_for_unit("gitea.service")
-      machine.wait_for_open_port(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;
+let
+  supportedDbTypes = [ "mysql" "postgres" "sqlite3" ];
+  makeGiteaTest = type: nameValuePair type (makeTest {
+    name = "gitea-${type}";
+    meta.maintainers = with maintainers; [ aanderse kolaente ma27 ];
+    machine = { config, pkgs, ... }: {
+      services.gitea = {
+        enable = true;
+        database = { inherit type; };
+        disableRegistration = true;
       };
+    };
 
     testScript = ''
       start_all()
@@ -65,5 +29,7 @@ with pkgs.lib;
           "curl --fail http://localhost:3000/user/sign_up | grep 'Registration is disabled. Please contact your site administrator.'"
       )
     '';
-  };
-}
+  });
+in
+
+listToAttrs (map makeGiteaTest supportedDbTypes)