Merge pull request 'Inventory/tests: add more eval smoke tests' (#2226) from hsjobeki/clan-core:hsjobeki-main into main
This commit is contained in:
@@ -98,7 +98,12 @@ let
|
||||
roleModules = builtins.map (
|
||||
role:
|
||||
let
|
||||
path = clan-core.clanModules.${serviceName} + "/roles/${role}.nix";
|
||||
# Check the module exists
|
||||
module =
|
||||
clan-core.clanModules.${serviceName}
|
||||
or (throw "ClanModule not found: '${serviceName}'. Make sure the module is added in the 'clanModules' attribute of clan-core.");
|
||||
|
||||
path = module + "/roles/${role}.nix";
|
||||
in
|
||||
if builtins.pathExists path then
|
||||
path
|
||||
|
||||
@@ -17,13 +17,6 @@ in
|
||||
...
|
||||
}:
|
||||
let
|
||||
inventory = (
|
||||
import ./build-inventory {
|
||||
clan-core = self;
|
||||
inherit lib;
|
||||
}
|
||||
);
|
||||
|
||||
getSchema = import ./interface-to-schema.nix { inherit lib self; };
|
||||
|
||||
# The schema for the inventory, without default values, from the module system.
|
||||
@@ -125,7 +118,7 @@ in
|
||||
|
||||
# Run: nix-unit --extra-experimental-features flakes --flake .#legacyPackages.x86_64-linux.evalTests
|
||||
legacyPackages.evalTests-inventory = import ./tests {
|
||||
inherit inventory;
|
||||
inherit lib;
|
||||
clan-core = self;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
{ inventory, clan-core, ... }:
|
||||
{ clan-core, lib, ... }:
|
||||
let
|
||||
inventory = (
|
||||
import ../build-inventory {
|
||||
|
||||
inherit lib clan-core;
|
||||
}
|
||||
);
|
||||
|
||||
inherit (inventory) buildInventory;
|
||||
in
|
||||
{
|
||||
@@ -120,6 +127,30 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
test_inventory_module_doesnt_exist =
|
||||
let
|
||||
configs = buildInventory {
|
||||
directory = ./.;
|
||||
inventory = {
|
||||
services = {
|
||||
fanatasy.instance_1 = {
|
||||
roles.default.machines = [ "machine_1" ];
|
||||
};
|
||||
};
|
||||
machines = {
|
||||
"machine_1" = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
expr = configs;
|
||||
expectedError = {
|
||||
type = "ThrownError";
|
||||
msg = "ClanModule not found*";
|
||||
};
|
||||
};
|
||||
|
||||
test_inventory_role_doesnt_exist =
|
||||
let
|
||||
configs = buildInventory {
|
||||
|
||||
Reference in New Issue
Block a user