summaryrefslogtreecommitdiffstats
path: root/nixos/tests
diff options
context:
space:
mode:
authorrnhmjoj <rnhmjoj@inventati.org>2020-11-02 01:34:53 +0100
committerrnhmjoj <rnhmjoj@inventati.org>2021-01-11 08:41:15 +0100
commitb7ca2d144893b44fa5baacfdcf019682070d72a3 (patch)
treed2dd60935a22608bf31e7e5efffb2fbde6a236de /nixos/tests
parent7ec85073ddfbedd1d0272bddd077a02798b1a4d4 (diff)
nixos/tests: add searx test
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/searx.nix62
2 files changed, 63 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index d53c6f6511e3..7d83b952f948 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -342,6 +342,7 @@ in
sbt-extras = handleTest ./sbt-extras.nix {};
scala = handleTest ./scala.nix {};
sddm = handleTest ./sddm.nix {};
+ searx = handleTest ./searx.nix {};
service-runner = handleTest ./service-runner.nix {};
shadow = handleTest ./shadow.nix {};
shadowsocks = handleTest ./shadowsocks {};
diff --git a/nixos/tests/searx.nix b/nixos/tests/searx.nix
new file mode 100644
index 000000000000..128c2a9381b2
--- /dev/null
+++ b/nixos/tests/searx.nix
@@ -0,0 +1,62 @@
+import ./make-test-python.nix ({ pkgs, ...} :
+
+{
+ name = "searx";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ rnhmjoj ];
+ };
+
+ machine = { ... }: {
+ imports = [ ../modules/profiles/minimal.nix ];
+
+ services.searx = {
+ enable = true;
+ environmentFile = pkgs.writeText "secrets" ''
+ WOLFRAM_API_KEY = sometoken
+ SEARX_SECRET_KEY = somesecret
+ '';
+
+ settings.server =
+ { port = 8080;
+ bind_address = "0.0.0.0";
+ secret_key = "@SEARX_SECRET_KEY@";
+ };
+
+ settings.engines = {
+ wolframalpha =
+ { api_key = "@WOLFRAM_API_KEY@";
+ engine = "wolframalpha_api";
+ };
+ startpage.shortcut = "start";
+ };
+
+ };
+ };
+
+ testScript =
+ ''
+ start_all()
+
+ with subtest("Settings have been merged"):
+ machine.wait_for_unit("searx")
+ output = machine.succeed(
+ "${pkgs.yq-go}/bin/yq r /var/lib/searx/settings.yml"
+ " 'engines.(name==startpage).shortcut'"
+ ).strip()
+ assert output == "start", "Settings not merged"
+
+ with subtest("Environment variables have been substituted"):
+ machine.succeed("grep -q somesecret /var/lib/searx/settings.yml")
+ machine.succeed("grep -q sometoken /var/lib/searx/settings.yml")
+
+ with subtest("Searx service is running"):
+ machine.wait_for_open_port(8080)
+ machine.succeed(
+ "${pkgs.curl}/bin/curl --fail http://localhost:8080"
+ )
+
+ machine.copy_from_vm("/var/lib/searx/settings.yml")
+ machine.shutdown()
+ '';
+})
+