From 534e2170208abc5b599ae4de1e8d1865bde526e2 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Tue, 8 Oct 2024 12:24:53 +0200 Subject: [PATCH] Inventory/enabled: add eval test --- lib/inventory/build-inventory/default.nix | 2 +- lib/inventory/tests/default.nix | 29 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/inventory/build-inventory/default.nix b/lib/inventory/build-inventory/default.nix index acb4756ef..5b5b53a4d 100644 --- a/lib/inventory/build-inventory/default.nix +++ b/lib/inventory/build-inventory/default.nix @@ -120,7 +120,7 @@ let globalExtraModules ++ machineExtraModules ++ roleServiceExtraModules ); in - if !serviceConfig.enabled then + if !(serviceConfig.enabled or true) then acc2 else if isInService then acc2 diff --git a/lib/inventory/tests/default.nix b/lib/inventory/tests/default.nix index 3b85191c0..2fea17c42 100644 --- a/lib/inventory/tests/default.nix +++ b/lib/inventory/tests/default.nix @@ -200,4 +200,33 @@ in msg = "no machine with tag '\\w+' found"; }; }; + test_inventory_disabled_service = + let + configs = buildInventory { + directory = ./.; + inventory = { + services = { + borgbackup.instance_1 = { + enabled = false; + roles.client.machines = [ "machine_1" ]; + }; + }; + machines = { + "machine_1" = { + + }; + }; + }; + }; + in + { + expr = { + machine_1_config = (builtins.head configs."machine_1"); + }; + expected = { + # Empty config + machine_1_config = { }; + }; + + }; }