Inventory: fix tests

This commit is contained in:
Johannes Kirschbauer
2024-07-15 16:52:24 +02:00
parent 9afed2295d
commit 7b18caca9b
3 changed files with 64 additions and 48 deletions

View File

@@ -93,7 +93,6 @@ let
roleServiceConfigs = builtins.map (
role: serviceConfig.roles.${role}.config or { }
) inverseRoles.${machineName} or [ ];
dbg = v: lib.traceSeq v v;
customImports = map (s: "${directory}/${s}") (
globalImports ++ machineImports ++ roleServiceImports
@@ -104,7 +103,7 @@ let
acc2
++ [
{
imports = dbg ([ clan-core.clanModules.${moduleName} ] ++ roleModules ++ customImports);
imports = [ clan-core.clanModules.${moduleName} ] ++ roleModules ++ customImports;
config.clan.${moduleName} = lib.mkMerge (
[
globalConfig

View File

@@ -43,7 +43,6 @@ let
importsOption = lib.mkOption {
default = [ ];
type = t.listOf t.str;
# apply = map (pathOrString: "${pathOrString}");
};
in
{

View File

@@ -2,12 +2,17 @@
{
test_inventory_empty = {
# Empty inventory should return an empty module
expr = buildInventory { };
expr = buildInventory {
inventory = { };
directory = ./.;
};
expected = { };
};
test_inventory_role_imports =
let
configs = buildInventory {
directory = ./.;
inventory = {
services = {
borgbackup.instance_1 = {
roles.server.machines = [ "backup_server" ];
@@ -23,6 +28,7 @@
"client_2_machine" = { };
};
};
};
in
{
expr = {
@@ -49,6 +55,8 @@
test_inventory_tag_resolve =
let
configs = buildInventory {
directory = ./.;
inventory = {
services = {
borgbackup.instance_1 = {
roles.client.tags = [ "backup" ];
@@ -64,6 +72,7 @@
};
};
};
};
in
{
expr = {
@@ -85,6 +94,8 @@
test_inventory_multiple_roles =
let
configs = buildInventory {
directory = ./.;
inventory = {
services = {
borgbackup.instance_1 = {
roles.client.machines = [ "machine_1" ];
@@ -95,6 +106,7 @@
"machine_1" = { };
};
};
};
in
{
expr = {
@@ -112,6 +124,8 @@
test_inventory_role_doesnt_exist =
let
configs = buildInventory {
directory = ./.;
inventory = {
services = {
borgbackup.instance_1 = {
roles.roleXYZ.machines = [ "machine_1" ];
@@ -121,6 +135,7 @@
"machine_1" = { };
};
};
};
in
{
expr = configs;
@@ -132,6 +147,8 @@
test_inventory_tag_doesnt_exist =
let
configs = buildInventory {
directory = ./.;
inventory = {
services = {
borgbackup.instance_1 = {
roles.client.machines = [ "machine_1" ];
@@ -144,6 +161,7 @@
};
};
};
};
in
{
expr = configs;