summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Gazzetta <fgaz@fgaz.me>2022-05-25 17:07:42 +0200
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2022-07-01 09:36:43 +0000
commit5f85d74552ad2761672fdc950cc711118d6b14b7 (patch)
tree0c3a6963bd0e3707c712d8bfcb4373c3d2653df4
parentlib.formats.keyValue: init (diff)
downloadnixpkgs-origin/backport-178365-to-release-22.05.tar.gz
formats.keyValue: add testsorigin/backport-178365-to-release-22.05
(cherry picked from commit 0d2842a4353f55eb2fc79ec7ad6490c1f5a2b88e)
-rw-r--r--pkgs/pkgs-lib/tests/formats.nix45
1 files changed, 45 insertions, 0 deletions
diff --git a/pkgs/pkgs-lib/tests/formats.nix b/pkgs/pkgs-lib/tests/formats.nix
index dba7f981cbd9..80df247f7b6a 100644
--- a/pkgs/pkgs-lib/tests/formats.nix
+++ b/pkgs/pkgs-lib/tests/formats.nix
@@ -147,6 +147,51 @@ in runBuildTests {
'';
};
+ testKeyValueAtoms = {
+ drv = evalFormat formats.keyValue {} {
+ bool = true;
+ int = 10;
+ float = 3.141;
+ str = "string";
+ };
+ expected = ''
+ bool=true
+ float=3.141000
+ int=10
+ str=string
+ '';
+ };
+
+ testKeyValueDuplicateKeys = {
+ drv = evalFormat formats.keyValue { listsAsDuplicateKeys = true; } {
+ bar = [ null true "test" 1.2 10 ];
+ baz = false;
+ qux = "qux";
+ };
+ expected = ''
+ bar=null
+ bar=true
+ bar=test
+ bar=1.200000
+ bar=10
+ baz=false
+ qux=qux
+ '';
+ };
+
+ testKeyValueListToValue = {
+ drv = evalFormat formats.keyValue { listToValue = concatMapStringsSep ", " (generators.mkValueStringDefault {}); } {
+ bar = [ null true "test" 1.2 10 ];
+ baz = false;
+ qux = "qux";
+ };
+ expected = ''
+ bar=null, true, test, 1.200000, 10
+ baz=false
+ qux=qux
+ '';
+ };
+
testTomlAtoms = {
drv = evalFormat formats.toml {} {
false = false;