Skip to content

Commit a61384a

Browse files
committed
Add a test case for #5904 (#3)
1 parent f891003 commit a61384a

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

api/krusty/list_order_test.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright 2022 The Kubernetes Authors.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package krusty_test
5+
6+
import (
7+
"testing"
8+
9+
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
10+
)
11+
12+
func TestStableListOrderAfterStrategicMergePatch(t *testing.T) {
13+
14+
th := kusttest_test.MakeHarness(t)
15+
th.WriteF("base.yaml", `
16+
apiVersion: v1
17+
kind: Pod
18+
metadata:
19+
name: example
20+
spec:
21+
containers:
22+
- name: example
23+
env:
24+
- name: ALFA
25+
value: alfa
26+
- name: BRAVO
27+
value: bravo
28+
- name: CHARLIE
29+
value: charlie
30+
- name: DELTA
31+
value: delta
32+
- name: LAST
33+
value: "$(DELTA)$(ALFA)$(DELTA)"
34+
`)
35+
36+
th.WriteF("patch.yaml", `
37+
apiVersion: v1
38+
kind: Pod
39+
metadata:
40+
name: example
41+
spec:
42+
containers:
43+
- name: example
44+
env:
45+
- name: LAST
46+
value: "$(ALFA)$(DELTA)$(ALFA)"
47+
`)
48+
th.WriteK(".", `
49+
resources:
50+
- base.yaml
51+
patches:
52+
- path: patch.yaml
53+
`)
54+
55+
m := th.Run(".", th.MakeDefaultOptions())
56+
th.AssertActualEqualsExpected(m, `
57+
apiVersion: v1
58+
kind: Pod
59+
metadata:
60+
name: example
61+
spec:
62+
containers:
63+
- name: example
64+
env:
65+
- name: ALFA
66+
value: alfa
67+
- name: BRAVO
68+
value: bravo
69+
- name: CHARLIE
70+
value: charlie
71+
- name: DELTA
72+
value: delta
73+
- name: LAST
74+
value: "$(ALFA)$(DELTA)$(ALFA)"
75+
`)
76+
}

0 commit comments

Comments
 (0)