From 1a78f721e65e112260ea942d8414849bb4dc09ef Mon Sep 17 00:00:00 2001 From: kurogeek Date: Thu, 20 Nov 2025 15:15:14 +0700 Subject: [PATCH] mob next [ci-skip] [ci skip] [skip ci] lastFile:tests/tests/think-gtcm.nix --- flake.nix | 1 + .../{think-greater-cm.nix => think-gtcm.nix} | 2 +- tests/default.nix | 17 ++++++++++++++ tests/lib.nix | 18 +++++++++++++++ tests/tests/think-gtcm.nix | 22 +++++++++++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) rename modules/nixos/{think-greater-cm.nix => think-gtcm.nix} (98%) create mode 100644 tests/default.nix create mode 100644 tests/lib.nix create mode 100644 tests/tests/think-gtcm.nix diff --git a/flake.nix b/flake.nix index 5c9d452..30fb5cb 100644 --- a/flake.nix +++ b/flake.nix @@ -45,6 +45,7 @@ ./routers ./inventories ./overlays + ./tests ./modules/clan/flake-module.nix ./modules/nixos/flake-module.nix ]; diff --git a/modules/nixos/think-greater-cm.nix b/modules/nixos/think-gtcm.nix similarity index 98% rename from modules/nixos/think-greater-cm.nix rename to modules/nixos/think-gtcm.nix index ec7489c..82ef2e3 100644 --- a/modules/nixos/think-greater-cm.nix +++ b/modules/nixos/think-gtcm.nix @@ -220,7 +220,7 @@ in virtualHosts."${cfg.domain}" = { root = "${cfg.stateDir}/public"; locations."~ \\.php$".extraConfig = '' - fastcgi_pass unix:${config.services.phpfpm.pools.flarum.socket}; + fastcgi_pass unix:${config.services.phpfpm.pools.think-greaterchiangmai.socket}; fastcgi_index site.php; ''; extraConfig = '' diff --git a/tests/default.nix b/tests/default.nix new file mode 100644 index 0000000..89a6595 --- /dev/null +++ b/tests/default.nix @@ -0,0 +1,17 @@ +{ ... }: +{ + perSystem = + { pkgs, self', ... }: + { + checks = + let + checkArgs = { + inherit pkgs; + self = self'; + }; + in + { + think-gtcm = import ./tests/think-gtcm.nix checkArgs; + }; + }; +} diff --git a/tests/lib.nix b/tests/lib.nix new file mode 100644 index 0000000..08b33c9 --- /dev/null +++ b/tests/lib.nix @@ -0,0 +1,18 @@ +test: +# These arguments are provided by `flake.nix` on import, see checkArgs +{ pkgs, self }: +let + inherit (pkgs) lib; + # this imports the nixos library that contains our testing framework + nixos-lib = import (pkgs.path + "/nixos/lib") { }; +in +(nixos-lib.runTest { + hostPkgs = pkgs; + # This speeds up the evaluation by skipping evaluating documentation (optional) + defaults.documentation.enable = lib.mkDefault false; + # This makes `self` available in the NixOS configuration of our virtual machines. + # This is useful for referencing modules or packages from your own flake + # as well as importing from other flakes. + node.specialArgs = { inherit self; }; + imports = [ test ]; +}).config.result diff --git a/tests/tests/think-gtcm.nix b/tests/tests/think-gtcm.nix new file mode 100644 index 0000000..34c7f4d --- /dev/null +++ b/tests/tests/think-gtcm.nix @@ -0,0 +1,22 @@ +(import ../lib.nix) { + name = "think-gtcm"; + nodes = { + # `self` here is set by using specialArgs in `lib.nix` + node1 = + { self, pkgs, ... }: + { + imports = [ ]; + services.think-greaterchiangmai = { + enable = true; + }; + }; + }; + # This is the test code that will check if our service is running correctly: + testScript = '' + start_all() + + node1.wait_for_unit("think-greaterchiangmai") + node1.wait_for_open_port(80) + output = node1.succeed("curl localhost") + ''; +}