Fix(tests/inventory): fix test assertions due to change in the exported structure

This commit is contained in:
Johannes Kirschbauer
2025-06-03 18:30:04 +02:00
parent 43e85b5482
commit bbbc13c973
2 changed files with 32 additions and 18 deletions

View File

@@ -190,7 +190,7 @@ in
acc: _module_ident: eval: acc: _module_ident: eval:
acc ++ [ eval.config.result.final.${machineName}.nixosModule or { } ] acc ++ [ eval.config.result.final.${machineName}.nixosModule or { } ]
) [ ] importedModulesEvaluated; ) [ ] importedModulesEvaluated;
}) inventory.machines; }) inventory.machines or { };
in in
{ {
inherit inherit

View File

@@ -88,25 +88,37 @@ let
roles.peer.tags.all = { }; roles.peer.tags.all = { };
}; };
}; };
/*
1 { imports = [ { instanceName = "instance_foo"; machine = { name = "jon"; roles = [ "controller" "pe 1 null
. er" ]; }; roles = { controller = { machines = { jon = { settings = { }; }; }; settings = { }; }; pe .
. er = { machines = { jon = { settings = { timeout = "foo-peer-jon"; }; }; }; settings = { timeout = .
. "foo-peer"; }; }; }; settings = { timeout = "foo-peer-jon"; }; vendoredSettings = { timeout = "conf .
. ig.thing"; }; } ]; } .
*/
unwrapModule = m: (builtins.head m.imports);
in in
{ {
# settings should evaluate # settings should evaluate
test_per_instance_arguments = { test_per_instance_arguments = {
expr = { expr =
instanceName = let
res.importedModulesEvaluated.self-A.config.result.allRoles.peer.allInstances."instance_foo".allMachines.jon.nixosModule.instanceName; m = (
unwrapModule
res.importedModulesEvaluated.self-A.config.result.allRoles.peer.allInstances."instance_foo".allMachines.jon.nixosModule
);
in
{
instanceName = m.instanceName;
# settings are specific. # settings are specific.
# Below we access: # Below we access:
# instance = instance_foo # instance = instance_foo
# roles = peer # roles = peer
# machines = jon # machines = jon
settings = settings = m.settings;
res.importedModulesEvaluated.self-A.config.result.allRoles.peer.allInstances.instance_foo.allMachines.jon.nixosModule.settings; machine = m.machine;
machine = roles = m.roles;
res.importedModulesEvaluated.self-A.config.result.allRoles.peer.allInstances.instance_foo.allMachines.jon.nixosModule.machine;
roles =
res.importedModulesEvaluated.self-A.config.result.allRoles.peer.allInstances.instance_foo.allMachines.jon.nixosModule.roles;
}; };
expected = { expected = {
instanceName = "instance_foo"; instanceName = "instance_foo";
@@ -147,10 +159,12 @@ in
}; };
}; };
# TODO: Cannot be tested like this anymore
test_per_instance_settings_vendoring = { test_per_instance_settings_vendoring = {
expr = expr =
(unwrapModule
res.importedModulesEvaluated.self-A.config.result.allRoles.peer.allInstances."instance_foo".allMachines.jon.nixosModule.vendoredSettings; res.importedModulesEvaluated.self-A.config.result.allRoles.peer.allInstances."instance_foo".allMachines.jon.nixosModule
).vendoredSettings;
expected = { expected = {
timeout = "config.thing"; timeout = "config.thing";
}; };