diff options
author | Robert Hensing <robert@roberthensing.nl> | 2023-06-26 12:50:01 +0200 |
---|---|---|
committer | Naïm Favier <n@monade.li> | 2023-06-27 11:48:53 +0200 |
commit | 18111335ed4e9bd80243987b30d8c7705a95c8e1 (patch) | |
tree | ec1a0f103bd20a29a79f25c43bb25df141fb6be4 | |
parent | 0179d9f7e608b6e54fd1399689b335db360fc9e5 (diff) | |
download | nixpkgs-18111335ed4e9bd80243987b30d8c7705a95c8e1.tar nixpkgs-18111335ed4e9bd80243987b30d8c7705a95c8e1.tar.gz nixpkgs-18111335ed4e9bd80243987b30d8c7705a95c8e1.tar.bz2 nixpkgs-18111335ed4e9bd80243987b30d8c7705a95c8e1.tar.lz nixpkgs-18111335ed4e9bd80243987b30d8c7705a95c8e1.tar.xz nixpkgs-18111335ed4e9bd80243987b30d8c7705a95c8e1.tar.zst nixpkgs-18111335ed4e9bd80243987b30d8c7705a95c8e1.zip |
lib/tests/modules.sh: Test types.pathInStore
Add missing test cases. I think the .links case should be rejected even though it's technically a path in the store.
-rwxr-xr-x | lib/tests/modules.sh | 10 | ||||
-rw-r--r-- | lib/tests/modules/types.nix | 24 |
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index a60228198fd..c81febb4156 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -63,6 +63,16 @@ checkConfigOutput '^"one two"$' config.result ./shorthand-meta.nix checkConfigOutput '^true$' config.result ./test-mergeAttrDefinitionsWithPrio.nix +# types.pathInStore +checkConfigOutput '".*/store/5lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix +checkConfigOutput '".*/store/xfb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"' config.pathInStore.ok2 ./types.nix +checkConfigOutput '".*/store/xfb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15/bin/bash"' config.pathInStore.ok3 ./types.nix +checkConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ""' config.pathInStore.bad1 ./types.nix +checkConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store"' config.pathInStore.bad2 ./types.nix +checkConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store/"' config.pathInStore.bad3 ./types.nix +checkConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store/.links"' config.pathInStore.bad4 ./types.nix +checkConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: "/foo/bar"' config.pathInStore.bad5 ./types.nix + # Check boolean option. checkConfigOutput '^false$' config.enable ./declare-enable.nix checkConfigError 'The option .* does not exist. Definition values:\n\s*- In .*: true' config.enable ./define-enable.nix diff --git a/lib/tests/modules/types.nix b/lib/tests/modules/types.nix new file mode 100644 index 00000000000..576db6b5b9e --- /dev/null +++ b/lib/tests/modules/types.nix @@ -0,0 +1,24 @@ +{ lib, ... }: +let + inherit (builtins) + storeDir; + inherit (lib) + types + mkOption + ; +in +{ + options = { + pathInStore = mkOption { type = types.lazyAttrsOf types.pathInStore; }; + }; + config = { + pathInStore.ok1 = "${storeDir}/5lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"; + pathInStore.ok2 = "${storeDir}/xfb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"; + pathInStore.ok3 = "${storeDir}/xfb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15/bin/bash"; + pathInStore.bad1 = ""; + pathInStore.bad2 = "${storeDir}"; + pathInStore.bad3 = "${storeDir}/"; + pathInStore.bad4 = "${storeDir}/.links"; # technically true, but not reasonable + pathInStore.bad5 = "/foo/bar"; + }; +} |