mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
tests/types: add suboptions doc test
Verify we are able to extract suboptions properly with our custom lib extension. Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
@@ -298,4 +298,7 @@ in
|
||||
in
|
||||
builtins.toJSON result.config.meta.maintainers
|
||||
);
|
||||
|
||||
# Unstable, for tests.
|
||||
_internal = { inherit docsLib; };
|
||||
}
|
||||
|
||||
@@ -2,5 +2,7 @@
|
||||
lib-types-dag-submodule = ./dag-submodule.nix;
|
||||
lib-types-dag-merge = ./dag-merge.nix;
|
||||
|
||||
lib-types-either-suboptions-docs-lib = ./either-suboptions-docs-lib.nix;
|
||||
|
||||
lib-types-gvariant-merge = ./gvariant-merge.nix;
|
||||
}
|
||||
|
||||
49
tests/lib/types/either-suboptions-docs-lib.nix
Normal file
49
tests/lib/types/either-suboptions-docs-lib.nix
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) mkOption;
|
||||
|
||||
docs = import ../../../docs {
|
||||
inherit pkgs lib;
|
||||
inherit (config.home.version) release isReleaseBranch;
|
||||
};
|
||||
|
||||
inherit (docs._internal.docsLib) types;
|
||||
|
||||
scalarOrSubmodule = types.either types.str (
|
||||
types.submodule {
|
||||
options = {
|
||||
foo = mkOption { type = types.str; };
|
||||
bar = mkOption { type = types.int; };
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
scalarOrSubmoduleSubOptions = scalarOrSubmodule.getSubOptions [ ];
|
||||
nullOrScalarOrSubmoduleSubOptions = (types.nullOr scalarOrSubmodule).getSubOptions [ ];
|
||||
in
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = scalarOrSubmoduleSubOptions ? foo;
|
||||
message = "docsLib.types.either should expose submodule options when one side is scalar.";
|
||||
}
|
||||
{
|
||||
assertion = scalarOrSubmoduleSubOptions ? bar;
|
||||
message = "docsLib.types.either should expose all submodule options when one side is scalar.";
|
||||
}
|
||||
{
|
||||
assertion = nullOrScalarOrSubmoduleSubOptions ? foo;
|
||||
message = "docsLib.types.nullOr (types.either ...) should keep submodule options visible.";
|
||||
}
|
||||
{
|
||||
assertion = nullOrScalarOrSubmoduleSubOptions ? bar;
|
||||
message = "docsLib.types.nullOr (types.either ...) should keep all submodule options visible.";
|
||||
}
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user