From 58a0db78613e772e0b82a265bb1fb6393f218f7e Mon Sep 17 00:00:00 2001 From: Skryta Istota <6970043-hidden-being@users.noreply.gitlab.com> Date: Sun, 30 Nov 2025 11:22:55 +0100 Subject: [PATCH] tests(cilib_test) Extended test definition for the ci lib Extended the definition of tests for the continuous integration library, allowing for more in-depth testing of odd behavior of some library functions. --- tests/cilib_test.nix | 192 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 164 insertions(+), 28 deletions(-) diff --git a/tests/cilib_test.nix b/tests/cilib_test.nix index 78e99a3..02d1d29 100644 --- a/tests/cilib_test.nix +++ b/tests/cilib_test.nix @@ -56,24 +56,59 @@ } { name = "jobPatched nix disabled"; - expected = {}; + expected = { + /*cache = [{ + name = "some"; + paths = [ "this" ]; + }]; + variables = { + BASH = toString pkgs.bash; + TEST = "work"; + };*/ + }; actual = mkJobPatched { key = "test"; pipelineName = "test"; - job = {}; + job = { + cache = [{ + name = "some"; + paths = [ "this" ]; + }]; + variables = { + BASH = toString pkgs.bash; + TEST = "work"; + }; + }; nixConfig.enable = false; }; } { name = "jobPatched without runner cache"; expected = { - after_script = ["finalize_nix_ci"]; - before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\""]; + after_script = [ "finalize_nix_ci" ]; + before_script = [ "source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\"" ]; + variables = { + #BASH = toString pkgs.bash; + TEST = "work"; + }; + cache = [{ + name = "some"; + paths = [ "this" ]; + }]; }; actual = mkJobPatched { key = "test"; pipelineName = "test"; - job = {}; + job = { + cache = [{ + name = "some"; + paths = [ "this" ]; + }]; + variables = { + BASH = toString pkgs.bash; + TEST = "work"; + }; + }; nixConfig = { enable = true; enableRunnerCache = false; @@ -83,20 +118,34 @@ { name = "jobPatched with runner cache"; expected = { - after_script = ["finalize_nix_ci"]; - before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\""]; - cache = [ - { - key = "test"; - paths = [".nix-cache/"]; - } - ]; - variables."NIX_CI_CACHE_STRATEGY" = "runner"; + after_script = [ "finalize_nix_ci" ]; + before_script = [ "source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\"" ]; + cache = [{ + name = "some"; + paths = [ "this" ]; + }{ + key = "test"; + paths = [ ".nix-cache/" ]; + }]; + variables = { + NIX_CI_CACHE_STRATEGY = "runner"; + #BASH = toString pkgs.bash; + TEST = "work"; + }; }; actual = mkJobPatched { key = "test"; pipelineName = "test"; - job = {}; + job = { + cache = [{ + name = "some"; + paths = [ "this" ]; + }]; + variables = { + BASH = toString pkgs.bash; + TEST = "work"; + }; + }; nixConfig = { enable = true; enableRunnerCache = true; @@ -145,23 +194,110 @@ ''; } { - name = "handle store paths in variables"; + name = "handle store paths in variables without nix config"; expected = { - stages = ["test"]; - test.stage = "test"; + stages = [ "test" ]; + variables = { + EXAMPLE = "empty"; + CURL = toString pkgs.curl; + }; + test = { + stage = "test"; + before_script = [ "./init" ]; + script = [ "echo Hello World!" ]; + after_script = [ "./clean" ]; + /*cache = [{ + key = "simple"; + paths = [ "~/random/" ]; + }]; + variables = { + SAMPLE = "working"; + HELLO = toString pkgs.hello; + };*/ + }; }; - actual = - (mkPipeline { - name = "test"; - nixConfig.enable = false; - pipeline = { - stages = ["test"]; - jobs.test = { - stage = "test"; - variables."TEST" = "${pkgs.hello}"; + actual = (mkPipeline { + name = "test"; + nixConfig.enable = false; + pipeline = { + stages = [ "test" ]; + variables = { + EXAMPLE = "empty"; + CURL = toString pkgs.curl; + }; + jobs.test = { + stage = "test"; + before_script = [ "./init" ]; + script = [ "echo Hello World!" ]; + after_script = [ "./clean" ]; + cache = [{ + key = "simple"; + paths = [ "~/random/" ]; + }]; + variables = { + SAMPLE = "working"; + HELLO = toString pkgs.hello; }; }; - }).finalConfig; + }; + }).finalConfig; + } + { + name = "handle store paths in variables with nix config"; + expected = { + stages = [ "test" ]; + variables = { + EXAMPLE = "empty"; + CURL = toString pkgs.curl; + }; + test = { + stage = "test"; + before_script = [ "source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\"" "./init" ]; + script = [ "echo Hello World!" ]; + after_script = [ "./clean" "finalize_nix_ci" ]; + cache = [{ + key = "simple"; + paths = [ "~/random/" ]; + }{ + key = "random"; + paths = [ ".nix-cache/" ]; + }]; + variables = { + SAMPLE = "working"; + #HELLO = toString pkgs.hello; + NIX_CI_CACHE_STRATEGY = "runner"; + }; + }; + }; + actual = (mkPipeline { + name = "test"; + nixConfig = { + enable = true; + enableRunnerCache = true; + runnerCacheKey = "random"; + }; + pipeline = { + stages = [ "test" ]; + variables = { + EXAMPLE = "empty"; + CURL = toString pkgs.curl; + }; + jobs.test = { + stage = "test"; + before_script = [ "./init" ]; + script = [ "echo Hello World!" ]; + after_script = [ "./clean" ]; + cache = [{ + key = "simple"; + paths = [ "~/random/" ]; + }]; + variables = { + SAMPLE = "working"; + HELLO = toString pkgs.hello; + }; + }; + }; + }).finalConfig; } ]; };