feat(test): support for enabling and disabling tests

This commit is contained in:
Jaka Hudoklin 2019-02-13 17:03:27 +01:00
parent ae3b208821
commit c1b84f3192
No known key found for this signature in database
GPG key ID: 6A08896BFD32BD95
2 changed files with 26 additions and 10 deletions

View file

@ -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 = {

View file

@ -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);
});
};
};