about summary refs log tree commit diff
path: root/lib/tests
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2022-04-06 19:02:36 +0200
committerGitHub <noreply@github.com>2022-04-06 19:02:36 +0200
commit180173a1c461eab9c04d50080374dcbbffcef712 (patch)
treed791e7eecebb90c0777f781c2a50653a792f8391 /lib/tests
parent2c95971556400c470211f475802e4a04804a79a0 (diff)
parent626ecc7bd72668e8624bfc3eac3635a1a31d1bf3 (diff)
Merge pull request #164088 from Profpatsch/lib.generators-add-toINIWithGlobalSection
lib.generators: add toINIWithGlobalSection
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/misc.nix60
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix
index 9012bba2b5675..fcccf89cc888c 100644
--- a/lib/tests/misc.nix
+++ b/lib/tests/misc.nix
@@ -471,6 +471,66 @@ runTests {
     '';
   };
 
+  testToINIWithGlobalSectionEmpty = {
+    expr = generators.toINIWithGlobalSection {} {
+      globalSection = {
+      };
+      sections = {
+      };
+    };
+    expected = ''
+    '';
+  };
+
+  testToINIWithGlobalSectionGlobalEmptyIsTheSameAsToINI =
+    let
+      sections = {
+        "section 1" = {
+          attribute1 = 5;
+          x = "Me-se JarJar Binx";
+        };
+        "foo" = {
+          "he\\h=he" = "this is okay";
+        };
+      };
+    in {
+      expr =
+        generators.toINIWithGlobalSection {} {
+            globalSection = {};
+            sections = sections;
+        };
+      expected = generators.toINI {} sections;
+  };
+
+  testToINIWithGlobalSectionFull = {
+    expr = generators.toINIWithGlobalSection {} {
+      globalSection = {
+        foo = "bar";
+        test = false;
+      };
+      sections = {
+        "section 1" = {
+          attribute1 = 5;
+          x = "Me-se JarJar Binx";
+        };
+        "foo" = {
+          "he\\h=he" = "this is okay";
+        };
+      };
+    };
+    expected = ''
+      foo=bar
+      test=false
+
+      [foo]
+      he\h\=he=this is okay
+
+      [section 1]
+      attribute1=5
+      x=Me-se JarJar Binx
+    '';
+  };
+
   /* right now only invocation check */
   testToJSONSimple =
     let val = {