Inventory: add assertions, allow external references

This commit is contained in:
Johannes Kirschbauer
2024-08-13 19:21:29 +02:00
parent 8fe2a40bcc
commit f0f870cf56
6 changed files with 157 additions and 48 deletions

View File

@@ -1,5 +1,37 @@
{ buildInventory, clan-core, ... }:
{ inventory, clan-core, ... }:
let
inherit (inventory) buildInventory getAllMachines;
in
{
test_get_all_used_machines = {
# Test that all machines are returned
expr = getAllMachines {
machines = {
machine_3 = {
tags = [ "tag_3" ];
};
};
services = {
borgbackup.instance_1 = {
roles.server.machines = [ "backup_server" ];
roles.client.machines = [
"client_1_machine"
"client_2_machine"
];
roles.client.tags = [ "tag_3" ];
};
};
};
expected = {
backup_server = { };
client_1_machine = { };
client_2_machine = { };
machine_3 = {
tags = [ "tag_3" ];
};
};
};
test_inventory_empty = {
# Empty inventory should return an empty module
expr = buildInventory {