File: fix-dotenv-test.patch

package info (click to toggle)
golang-github-knadh-koanf 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 808 kB
  • sloc: sh: 31; makefile: 14
file content (102 lines) | stat: -rw-r--r-- 3,378 bytes parent folder | download
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
From: Maytham Alsudany <maytha8thedev@gmail.com>
Forwarded: no
Description: fix dotenv test
 This patch replaces all dashes in key names with underscores. This addresses
 an intentional regression introduced in godotenv 1.5. parsers/dotenv/go.mod
 specifies godotenv 1.5, but I think this test was written with <=1.4.
 See https://github.com/joho/godotenv/issues/209
 .
 Minor fix to 'Mixed data types' test, unquoting the 12 at the end of the
 expected output.
 .
 The 'Missing quotation mark' test has been disabled because, AFAIK, <=1.4 used
 to ignore the fact that a quotation mark is missing and output '"value', but
 the latest version of godotenv errors.

--- a/parsers/dotenv/dotenv_test.go
+++ b/parsers/dotenv/dotenv_test.go
@@ -30,36 +30,36 @@
 		{
 			name: "Multiple key-values",
 			cfg: map[string]interface{}{
-				"key-1": "value-1",
-				"key-2": "value-2",
-				"key-3": "value-3",
+				"key_1": "value-1",
+				"key_2": "value-2",
+				"key_3": "value-3",
 			},
-			expOut: []byte("key-1=\"value-1\"\nkey-2=\"value-2\"\nkey-3=\"value-3\""),
+			expOut: []byte("key_1=\"value-1\"\nkey_2=\"value-2\"\nkey_3=\"value-3\""),
 		},
 		{
 			name: "Mixed data types",
 			cfg: map[string]interface{}{
-				"int-key":   12,
-				"bool-key":  true,
-				"arr-key":   []int{1, 2, 3, 4},
-				"float-key": 10.5,
+				"int_key":   12,
+				"bool_key":  true,
+				"arr_key":   []int{1, 2, 3, 4},
+				"float_key": 10.5,
 			},
-			expOut: []byte("arr-key=\"[1 2 3 4]\"\nbool-key=\"true\"\nfloat-key=\"10.5\"\nint-key=\"12\""),
+			expOut: []byte("arr_key=\"[1 2 3 4]\"\nbool_key=\"true\"\nfloat_key=\"10.5\"\nint_key=12"),
 		},
 		{
 			name: "Nested config",
 			cfg: map[string]interface{}{
-				"map-key": map[string]interface{}{
-					"arr-key":  []float64{1.2, 4.3, 5, 6},
-					"bool-key": false,
-					"inner-map-key": map[interface{}]interface{}{
+				"map_key": map[string]interface{}{
+					"arr_key":  []float64{1.2, 4.3, 5, 6},
+					"bool_key": false,
+					"inner_map_key": map[interface{}]interface{}{
 						0: "zero",
 						1: 1.0,
 					},
-					"int-key": 12,
+					"int_key": 12,
 				},
 			},
-			expOut: []byte(`map-key="map[arr-key:[1.2 4.3 5 6] bool-key:false inner-map-key:map[0:zero 1:1] int-key:12]"`),
+			expOut: []byte(`map_key="map[arr_key:[1.2 4.3 5 6] bool_key:false inner_map_key:map[0:zero 1:1] int_key:12]"`),
 		},
 	}
 
@@ -93,10 +93,10 @@
 		},
 		{
 			name: "Multiple key-values",
-			cfg:  []byte("key-1=\"value-1\"\nkey-2=\"value-2\""),
+			cfg:  []byte("key_1=\"value-1\"\nkey_2=\"value-2\""),
 			expOut: map[string]interface{}{
-				"key-1": "value-1",
-				"key-2": "value-2",
+				"key_1": "value-1",
+				"key_2": "value-2",
 			},
 		},
 		{
@@ -111,16 +111,9 @@
 		},
 		{
 			name: "Nested config",
-			cfg:  []byte(`map-key="map[arr-key:[1 4 5 6] bool-key:false inner-map-key:map[0:zero 1:1] int-key:12]"`),
+			cfg:  []byte(`map_key="map[arr_key:[1 4 5 6] bool_key:false inner_map_key:map[0:zero 1:1] int_key:12]"`),
 			expOut: map[string]interface{}{
-				"map-key": "map[arr-key:[1 4 5 6] bool-key:false inner-map-key:map[0:zero 1:1] int-key:12]",
-			},
-		},
-		{
-			name: "Missing quotation mark",
-			cfg:  []byte(`key="value`),
-			expOut: map[string]interface{}{
-				"key": `"value`,
+				"map_key": "map[arr_key:[1 4 5 6] bool_key:false inner_map_key:map[0:zero 1:1] int_key:12]",
 			},
 		},
 		{