Home

cuesonnet @main - refs - log -
-
https://git.jolheiser.com/cuesonnet.git
CUE + Jsonnet
tree log patch
add kitchen sink jsonnet test Signed-off-by: jolheiser <git@jolheiser.com>
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQGmO9Fu9MHSbZi1BpBjVRzGRa6NQFhLBzwC7QNwS1gthO4PxGHVVimxlFGA0i2jJJk M+QxWD5CEK4okrBSK4FQw= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
6 days ago
2 changed files, 31 additions(+), 6 deletions(-)
cuesonnet_test.gotestdata/kitchen.jsonnet
M cuesonnet_test.go -> cuesonnet_test.go
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
diff --git a/cuesonnet_test.go b/cuesonnet_test.go
index f645e5e0a14a69db43e7c6781c905d5a6c22d0c2..e867a77ca895f2f6e81a97c2e76e5bb86b7df6e3 100644
--- a/cuesonnet_test.go
+++ b/cuesonnet_test.go
@@ -17,6 +17,8 @@ 	//go:embed testdata/almost-fixed.jsonnet
 	almostFixed string
 	//go:embed testdata/fixed.jsonnet
 	fixed string
+	//go:embed testdata/kitchen.jsonnet
+	kitchen string
 )
 
 type Schema struct {
@@ -52,6 +54,13 @@ 			}
 		}
 	})
 
+	expect := Schema{
+		FirstName: "Jim",
+		LastName:  "Jimbly",
+		Age:       45,
+		Birthday:  "01/02/2003",
+		Gopher:    true,
+	}
 	t.Run("fixed", func(t *testing.T) {
 		t.Parallel()
 		var s Schema
@@ -59,12 +68,17 @@ 		if err := schema.Decode(strings.NewReader(fixed), &s); err != nil {
 			t.Logf("fixed config should not fail to decode: %v", err)
 			t.Fail()
 		}
-		expect := Schema{
-			FirstName: "Jim",
-			LastName:  "Jimbly",
-			Age:       45,
-			Birthday:  "01/02/2003",
-			Gopher:    true,
+		if s != expect {
+			t.Logf("did not get expected decoding: %+v != %+v", s, expect)
+			t.Fail()
+		}
+	})
+	t.Run("kitchen", func(t *testing.T) {
+		t.Parallel()
+		var s Schema
+		if err := schema.Decode(strings.NewReader(kitchen), &s); err != nil {
+			t.Logf("kitchen config should not fail to decode: %v", err)
+			t.Fail()
 		}
 		if s != expect {
 			t.Logf("did not get expected decoding: %+v != %+v", s, expect)
I testdata/kitchen.jsonnet
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
diff --git a/testdata/kitchen.jsonnet b/testdata/kitchen.jsonnet
new file mode 100644
index 0000000000000000000000000000000000000000..83c3c28d64873946900b6fd0062d44ee11c2bb90
--- /dev/null
+++ b/testdata/kitchen.jsonnet
@@ -0,0 +1,11 @@
+local name = 'Jim';
+local age = 45;
+
+local userData = function(name, age) {
+  firstName: name,
+  lastName: name + 'bly',
+  age: age,
+  birthday: '01/02/2003',
+};
+
+userData(name, age)