mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2026-02-02 11:25:07 +01:00
chore: split everything up into their own files & add a bunch of tests
This commit is contained in:
parent
b309fb59db
commit
2f197d2c50
20 changed files with 704 additions and 310 deletions
96
tests/helpers.nix
Normal file
96
tests/helpers.nix
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cilib = import ./../lib {inherit lib pkgs;};
|
||||
in {
|
||||
nixtest.suites."Helpers" = {
|
||||
pos = __curPos;
|
||||
tests = let
|
||||
inherit (cilib) helpers;
|
||||
in [
|
||||
{
|
||||
name = "appendToAfterScript nix disabled";
|
||||
expected = {};
|
||||
actual = helpers.appendToAfterScript [] {};
|
||||
}
|
||||
{
|
||||
name = "appendToAfterScript empty";
|
||||
expected = {
|
||||
nix.enable = true;
|
||||
after_script = [];
|
||||
};
|
||||
actual = helpers.appendToAfterScript [] {nix.enable = true;};
|
||||
}
|
||||
{
|
||||
name = "appendToAfterScript";
|
||||
expected = {
|
||||
nix.enable = true;
|
||||
after_script = ["echo after_script" "finalize_nix_ci"];
|
||||
};
|
||||
actual = helpers.appendToAfterScript ["finalize_nix_ci"] {
|
||||
nix.enable = true;
|
||||
after_script = ["echo after_script"];
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "prependToBeforeScript nix disabled";
|
||||
expected = {};
|
||||
actual = helpers.prependToBeforeScript [] {};
|
||||
}
|
||||
{
|
||||
name = "prependToBeforeScript empty";
|
||||
expected = {
|
||||
nix.enable = true;
|
||||
before_script = [];
|
||||
};
|
||||
actual = helpers.prependToBeforeScript [] {nix.enable = true;};
|
||||
}
|
||||
{
|
||||
name = "prependToBeforeScript";
|
||||
expected = {
|
||||
nix.enable = true;
|
||||
before_script = ["setup_nix_ci" "echo before_script"];
|
||||
};
|
||||
actual = helpers.prependToBeforeScript ["setup_nix_ci"] {
|
||||
nix.enable = true;
|
||||
before_script = ["echo before_script"];
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "toYaml";
|
||||
expected = ''{"hello":"world"}'';
|
||||
actual = builtins.readFile (helpers.toYaml "test" {hello = "world";});
|
||||
}
|
||||
{
|
||||
name = "filterAttrsRec";
|
||||
expected = {world = "world";};
|
||||
actual = helpers.filterAttrsRec (n: v: v != null) {
|
||||
hello = null;
|
||||
world = "world";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "filterJobVariables with store paths";
|
||||
expected = {HELLO = "${pkgs.hello}";};
|
||||
actual = helpers.filterJobVariables true {
|
||||
variables = {
|
||||
HELLO = "${pkgs.hello}";
|
||||
WORLD = "world";
|
||||
};
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "filterJobVariables without store paths";
|
||||
expected = {WORLD = "world";};
|
||||
actual = helpers.filterJobVariables false {
|
||||
variables = {
|
||||
HELLO = "${pkgs.hello}";
|
||||
WORLD = "world";
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue