clanServices: add tests for resolve modules
This commit is contained in:
@@ -18,6 +18,9 @@ in
|
|||||||
inherit lib;
|
inherit lib;
|
||||||
clanLib = self.clanLib;
|
clanLib = self.clanLib;
|
||||||
};
|
};
|
||||||
|
legacyPackages.eval-tests-resolve-module = import ./test-resolve-module.nix {
|
||||||
|
inherit lib;
|
||||||
|
};
|
||||||
|
|
||||||
checks = {
|
checks = {
|
||||||
eval-lib-distributedServices = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
|
eval-lib-distributedServices = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
|
||||||
@@ -30,6 +33,16 @@ in
|
|||||||
|
|
||||||
touch $out
|
touch $out
|
||||||
'';
|
'';
|
||||||
|
eval-tests-resolve-module = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
|
||||||
|
export HOME="$(realpath .)"
|
||||||
|
nix-unit --eval-store "$HOME" \
|
||||||
|
--extra-experimental-features flakes \
|
||||||
|
--show-trace \
|
||||||
|
${inputOverrides} \
|
||||||
|
--flake ${self}#legacyPackages.${system}.eval-tests-resolve-module
|
||||||
|
|
||||||
|
touch $out
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# Run: nix-unit ./test-resolve-module.nix
|
||||||
|
{
|
||||||
|
lib ? import <nixpkgs/lib>,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
resolveModule = import ./resolveModule.nix { inherit lib; };
|
||||||
|
|
||||||
|
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'";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user