diff --git a/tests/cilib_test.nix b/tests/cilib_test.nix index 1661c8c..3b76fb8 100644 --- a/tests/cilib_test.nix +++ b/tests/cilib_test.nix @@ -56,28 +56,26 @@ } { name = "jobPatched nix disabled"; + expected = {}; + actual = mkJobPatched { + key = "test"; + pipelineName = "test"; + job = {}; + nixConfig.enable = false; + }; + } + { + name = "jobPatched nix disabled with variables and cache"; expected = { - cache = { - name = "some"; - paths = ["this"]; - }; - variables = { - BASH = toString pkgs.bash; - TEST = "work"; - }; + variables."HELLO" = "world"; + cache = [{key = "example";}]; }; actual = mkJobPatched { key = "test"; pipelineName = "test"; job = { - cache = { - name = "some"; - paths = ["this"]; - }; - variables = { - BASH = toString pkgs.bash; - TEST = "work"; - }; + variables."HELLO" = "world"; + cache = [{key = "example";}]; }; nixConfig.enable = false; }; @@ -87,30 +85,11 @@ expected = { 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 = { - cache = { - name = "some"; - paths = ["this"]; - }; - variables = { - BASH = toString pkgs.bash; - TEST = "work"; - }; - }; + job = {}; nixConfig = { enable = true; enableRunnerCache = false; @@ -123,34 +102,17 @@ 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"; - }; + variables."NIX_CI_CACHE_STRATEGY" = "runner"; }; actual = mkJobPatched { key = "test"; pipelineName = "test"; - job = { - cache = { - name = "some"; - paths = ["this"]; - }; - variables = { - BASH = toString pkgs.bash; - TEST = "work"; - }; - }; + job = {}; nixConfig = { enable = true; enableRunnerCache = true; @@ -199,26 +161,12 @@ ''; } { - name = "handle store paths in variables without nix config"; + name = "ignore store paths in variables with nix disabled"; expected = { 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; - }; + variables."TEST" = "${pkgs.hello}"; }; }; actual = @@ -227,85 +175,32 @@ 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; - }; + variables."TEST" = "${pkgs.hello}"; }; }; }).finalConfig; } { - name = "handle store paths in variables with nix config"; + # it doesn't make much sense to have any nix store path in variables, but we ignore it for global variables + name = "ignore store paths in global variables"; expected = { - stages = ["test"]; variables = { - EXAMPLE = "empty"; + HELLO = "world"; 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"; - }; + nixConfig.enable = true; pipeline = { - stages = ["test"]; variables = { - EXAMPLE = "empty"; + HELLO = "world"; 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; - }; - }; + jobs = {}; }; }).finalConfig; }