Skip to content

Commit

Permalink
lib.attrsWith: init eval tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjobeki committed Sep 27, 2024
1 parent dc45ca2 commit ab4daed
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/tests/misc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,44 @@ runTests {
expected = [ [ "_module" "args" ] [ "foo" ] [ "foo" "<name>" "bar" ] [ "foo" "bar" ] ];
};

testAttrsWithName = {
expr = let
eval = evalModules {
modules = [
{
options = {
foo = lib.mkOption {
type = lib.types.attrsWith {
name = "MyCustomPlaceholder";
elemType = lib.types.submodule {
options.bar = lib.mkOption {
type = lib.types.int;
default = 42;
};
};
};
};
};
}
];
};
opt = eval.options.foo;
in
(opt.type.getSubOptions opt.loc).bar.loc;
expected = [
"foo"
"<MyCustomPlaceholder>"
"bar"
];
};

testShowOptionWithPlaceholder = {
# <name>, *, should now be escaped. It is used as a placeholder by convention.
# Other symbols should be escaped. `{}`
expr = lib.showOption ["<name>" "<myName>" "*" "{foo}"];
expected = "<name>.<myName>.*.\"{foo}\"";
};

testCartesianProductOfEmptySet = {
expr = cartesianProduct {};
expected = [ {} ];
Expand Down

0 comments on commit ab4daed

Please sign in to comment.