inventory: make resolve module a clanLib function

Unclutter inventory logic
This commit is contained in:
Johannes Kirschbauer
2025-09-16 13:09:56 +02:00
parent 0bce953c2f
commit f49df8d574
7 changed files with 70 additions and 31 deletions

View File

@@ -0,0 +1,70 @@
# Run: nix-unit ./test-resolve-module.nix
{
lib ? import <nixpkgs/lib>,
clanLib ? import ../default.nix { inherit lib; },
}:
let
resolveModule = clanLib.resolveModule;
fromSpec =
moduleSpec:
resolveModule {
inherit moduleSpec;
flakeInputs = {
self.clan.modules = {
foo = {
name = "self/foo";
};
};
};
clanCoreModules = {
foo = {
name = "clan/foo";
};
bar = {
name = "clan/bar";
};
};
};
in
{
test_default_clan_core = {
expr = fromSpec {
name = "foo";
input = null;
};
expected = {
name = "clan/foo";
};
};
test_self_module = {
expr = fromSpec {
name = "foo";
input = "self";
};
expected = {
name = "self/foo";
};
};
test_missing_self_module = {
expr = fromSpec {
name = "bar";
input = "self";
};
expectedError = {
type = "ThrownError";
msg = "flake input 'self' doesn't provide clan-module with name 'bar'";
};
};
test_missing_core_module = {
expr = fromSpec {
name = "nana";
input = null;
};
expectedError = {
type = "ThrownError";
msg = "clan-core doesn't provide clan-module with name 'nana'";
};
};
}