mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 08:00:06 +01:00
feat(test): support for enabling and disabling tests
This commit is contained in:
parent
ae3b208821
commit
c1b84f3192
2 changed files with 26 additions and 10 deletions
|
|
@ -14,6 +14,12 @@ with lib;
|
|||
type = types.str;
|
||||
};
|
||||
|
||||
enable = mkOption {
|
||||
description = "Whether to enable test";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
assertions = mkOption {
|
||||
type = types.listOf (types.submodule {
|
||||
options = {
|
||||
|
|
|
|||
|
|
@ -25,16 +25,14 @@ in {
|
|||
inherit modules;
|
||||
}).config.test;
|
||||
|
||||
evaled = builtins.trace "testing ${test.name}" (kubenix.evalKubernetesModules {
|
||||
evaled =
|
||||
if test.enable
|
||||
then builtins.trace "testing ${test.name}" (kubenix.evalKubernetesModules {
|
||||
inherit modules;
|
||||
});
|
||||
})
|
||||
else {success = false;};
|
||||
in {
|
||||
options = {
|
||||
module = mkOption {
|
||||
description = "Module defining submodule";
|
||||
type = types.unspecified;
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
description = "test name";
|
||||
type = types.str;
|
||||
|
|
@ -47,6 +45,17 @@ in {
|
|||
internal = true;
|
||||
};
|
||||
|
||||
enable = mkOption {
|
||||
description = "Whether to enable test";
|
||||
type = types.bool;
|
||||
internal = true;
|
||||
};
|
||||
|
||||
module = mkOption {
|
||||
description = "Module defining submodule";
|
||||
type = types.unspecified;
|
||||
};
|
||||
|
||||
evaled = mkOption {
|
||||
description = "Wheter test was evaled";
|
||||
type = types.bool;
|
||||
|
|
@ -73,11 +82,12 @@ in {
|
|||
};
|
||||
|
||||
config = {
|
||||
inherit (test) name description;
|
||||
inherit (test) name description enable;
|
||||
assertions = mkIf config.evaled evaled.config.test.assertions;
|
||||
success = mkIf config.evaled (all (el: el.assertion) config.assertions);
|
||||
};
|
||||
})));
|
||||
apply = tests: filter (test: test.enable) tests;
|
||||
};
|
||||
|
||||
testing.success = mkOption {
|
||||
|
|
@ -94,7 +104,7 @@ in {
|
|||
tests = map (test: {
|
||||
inherit (test) name description evaled success;
|
||||
assertions = moduleToAttrs test.assertions;
|
||||
}) cfg.tests;
|
||||
}) (filter (test: test.enable) cfg.tests);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue