lib/tests: Add test for freeform option docs

This commit is contained in:
Silvan Mosberger 2020-09-04 15:50:13 +02:00
parent ea5ba6e13d
commit f320dbae41
No known key found for this signature in database
GPG key ID: E8F1E9EAD284E17D

View file

@ -542,4 +542,30 @@ runTests {
name = "";
expected = "unknown";
};
testFreeformOptions = {
expr =
let
submodule = { lib, ... }: {
freeformType = lib.types.attrsOf (lib.types.submodule {
options.bar = lib.mkOption {};
});
options.bar = lib.mkOption {};
};
module = { lib, ... }: {
options.foo = lib.mkOption {
type = lib.types.submodule submodule;
};
};
options = (evalModules {
modules = [ module ];
}).options;
locs = filter (o: ! o.internal) (optionAttrSetToDocList options);
in map (o: o.loc) locs;
expected = [ [ "foo" ] [ "foo" "<name>" "bar" ] [ "foo" "bar" ] ];
};
}