testing: rename defaults to common options

They are technically no defaults and competing declarations cause a
module error
This commit is contained in:
David Arnold 2021-05-31 22:31:37 -05:00
parent 557cc48a0a
commit b29d3a11b2
No known key found for this signature in database
GPG key ID: 6D6A936E69C59D08
5 changed files with 18 additions and 18 deletions

View file

@ -19,10 +19,10 @@ let
tests = [ ./test.nix ]; tests = [ ./test.nix ];
docker.registryUrl = ""; docker.registryUrl = "";
# testing commonalities for tests that exhibit the respective feature # testing commonalities for tests that exhibit the respective feature
defaults = [ common = [
{ {
features = [ "k8s" ]; features = [ "k8s" ];
default = { options = {
kubernetes.version = "1.20"; kubernetes.version = "1.20";
}; };
} }

View file

@ -39,21 +39,21 @@ in
default = true; default = true;
}; };
defaults = mkOption { common = mkOption {
description = "List of defaults to apply to tests"; description = "List of common options to apply to tests";
type = types.listOf (types.submodule ({ config, ... }: { type = types.listOf (types.submodule ({ config, ... }: {
options = { options = {
features = mkOption { features = mkOption {
description = "List of features that test has to have to apply defaults"; description = "List of features that test has to have to apply options";
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [ ];
}; };
default = mkOption { options = mkOption {
description = "Default to apply to test"; description = "Options to apply to test";
type = types.unspecified; type = types.unspecified;
default = { }; default = { };
apply = default: { _file = "testing.defaults"; } // default; apply = default: { _file = "testing.common"; } // default;
}; };
}; };
})); }));

View file

@ -37,9 +37,9 @@ in
}; };
}; };
config.testing.defaults = [{ config.testing.common = [{
features = [ "docker" ]; features = [ "docker" ];
default = { options = {
_file = "testing.docker.registryUrl"; _file = "testing.docker.registryUrl";
docker.registry.url = cfg.registryUrl; docker.registry.url = cfg.registryUrl;
}; };

View file

@ -33,23 +33,23 @@ let
# test features # test features
testFeatures = evaled'.config._m.features; testFeatures = evaled'.config._m.features;
# defaults that can be applied on tests # common options that can be applied on this test
defaults = commonOpts =
filter filter
(d: (d:
(intersectLists d.features testFeatures) == d.features || (intersectLists d.features testFeatures) == d.features ||
(length d.features) == 0 (length d.features) == 0
) )
testing.defaults; testing.common;
# add default modules to all modules # add common options modules to all modules
modulesWithDefaults = modules ++ (map (d: d.default) defaults); modulesWithCommonOptions = modules ++ (map (d: d.options) commonOpts);
# evaled test # evaled test
evaled = evaled =
let let
evaled' = kubenix.evalModules { evaled' = kubenix.evalModules {
modules = modulesWithDefaults; modules = modulesWithCommonOptions;
}; };
in in
if testing.throwError then evaled' if testing.throwError then evaled'

View file

@ -40,10 +40,10 @@ let
args = { images = pkgs.callPackage ./images.nix { }; }; args = { images = pkgs.callPackage ./images.nix { }; };
docker.registryUrl = registry; docker.registryUrl = registry;
defaults = [ common = [
{ {
features = [ "k8s" ]; features = [ "k8s" ];
default = { options = {
kubernetes.version = k8sVersion; kubernetes.version = k8sVersion;
}; };
} }