From 9bba8deca0ed1591de7f8772c7469b957ea2f418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Serv=C3=A9n=20Mar=C3=ADn?= Date: Mon, 15 Feb 2021 12:50:02 +0100 Subject: [PATCH] testdata: add manifestJsonEx array test case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a test case to prevent regressions in std.manifestJsonEx accepting arrays as values. Signed-off-by: Lucas Servén Marín --- testdata/builtinManifestJsonEx.golden | 5 ++- testdata/builtinManifestJsonEx.jsonnet | 60 ++++++++++++++++++-------- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/testdata/builtinManifestJsonEx.golden b/testdata/builtinManifestJsonEx.golden index 731a2d3..58fa830 100644 --- a/testdata/builtinManifestJsonEx.golden +++ b/testdata/builtinManifestJsonEx.golden @@ -1 +1,4 @@ -"{\n \"bam\": true,\n \"bar\": \"bar\",\n \"baz\": 1,\n \"bazel\": 1.42,\n \"bim\": false,\n \"blamo\": {\n \"cereal\": [\n \"<>& fizbuzz\"\n ],\n \"treats\": [\n {\n \"name\": \"chocolate\"\n }\n ]\n },\n \"boom\": -1,\n \"foo\": \"bar\"\n}" +{ + "a": "{\n \"bam\": true,\n \"bar\": \"bar\",\n \"baz\": 1,\n \"bazel\": 1.42,\n \"bim\": false,\n \"blamo\": {\n \"cereal\": [\n \"<>& fizbuzz\"\n ],\n \"treats\": [\n {\n \"name\": \"chocolate\"\n }\n ]\n },\n \"boom\": -1,\n \"foo\": \"bar\"\n}", + "b": "[\n \"bar\",\n \"bar\",\n 1,\n 1.42,\n -1,\n false,\n true,\n {\n \"cereal\": [\n \"<>& fizbuzz\"\n ],\n \"treats\": [\n {\n \"name\": \"chocolate\"\n }\n ]\n }\n]" +} diff --git a/testdata/builtinManifestJsonEx.jsonnet b/testdata/builtinManifestJsonEx.jsonnet index c63139b..4d6cf99 100644 --- a/testdata/builtinManifestJsonEx.jsonnet +++ b/testdata/builtinManifestJsonEx.jsonnet @@ -1,22 +1,46 @@ local a = { - foo: "bar", - bar: self.foo, - baz: 1, - bazel: 1.42, - boom: -1, - bim: false, - bam: true, - blamo: { - cereal: [ - "<>& fizbuzz", - ], + foo: 'bar', + bar: self.foo, + baz: 1, + bazel: 1.42, + boom: -1, + bim: false, + bam: true, + blamo: { + cereal: [ + '<>& fizbuzz', + ], - treats: [ - { - name: "chocolate", - } - ], - } + treats: [ + { + name: 'chocolate', + }, + ], + }, }; -std.manifestJsonEx(a, " ") \ No newline at end of file +local b = [ + 'bar', + a.foo, + 1, + 1.42, + -1, + false, + true, + { + cereal: [ + '<>& fizbuzz', + ], + + treats: [ + { + name: 'chocolate', + }, + ], + }, +]; + +{ + a: std.manifestJsonEx(a, ' '), + b: std.manifestJsonEx(b, ' '), +}