Skip to content

Commit 6371a4d

Browse files
committed
simplify test
1 parent 24aa83d commit 6371a4d

File tree

1 file changed

+16
-38
lines changed

1 file changed

+16
-38
lines changed

merge/conflict_test.go

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package merge_test
1818

1919
import (
20-
"reflect"
2120
"testing"
2221

2322
"sigs.k8s.io/structured-merge-diff/v4/fieldpath"
@@ -95,42 +94,21 @@ func TestToSet(t *testing.T) {
9594
}
9695

9796
func TestConflictsFromManagers(t *testing.T) {
98-
type args struct {
99-
sets fieldpath.ManagedFields
100-
}
101-
tests := []struct {
102-
name string
103-
args args
104-
want string
105-
}{
106-
{
107-
name: "test with common prefix",
108-
args: args{
109-
sets: fieldpath.ManagedFields{
110-
"Bob": fieldpath.NewVersionedSet(
111-
_NS(
112-
_P("spec", "template", "spec", "containers", _KBF("name", "probe"), "livenessProbe", "exec", "command"),
113-
_P("spec", "template", "spec", "containers", _KBF("name", "probe"), "livenessProbe", "periodSeconds"),
114-
_P("spec", "template", "spec", "containers", _KBF("name", "probe"), "readinessProbe", "exec", "command"),
115-
_P("spec", "template", "spec", "containers", _KBF("name", "probe"), "readinessProbe", "periodSeconds"),
116-
),
117-
"v1",
118-
false,
119-
),
120-
},
121-
},
122-
want: `conflicts with "Bob":
123-
- .spec.template.spec.containers[name="probe"].livenessProbe.periodSeconds
124-
- .spec.template.spec.containers[name="probe"].livenessProbe.exec.command
125-
- .spec.template.spec.containers[name="probe"].readinessProbe.periodSeconds
126-
- .spec.template.spec.containers[name="probe"].readinessProbe.exec.command`,
127-
},
128-
}
129-
for _, tt := range tests {
130-
t.Run(tt.name, func(t *testing.T) {
131-
if got := merge.ConflictsFromManagers(tt.args.sets); !reflect.DeepEqual(got.Error(), tt.want) {
132-
t.Errorf("ConflictsFromManagers() = %v, want %v", got, tt.want)
133-
}
134-
})
97+
98+
got := merge.ConflictsFromManagers(fieldpath.ManagedFields{
99+
"Bob": fieldpath.NewVersionedSet(
100+
_NS(
101+
_P("obj", "template", "obj", "list", _KBF("name", "a"), "id"),
102+
_P("obj", "template", "obj", "list", _KBF("name", "a"), "key"),
103+
),
104+
"v1",
105+
false,
106+
),
107+
})
108+
wanted := `conflicts with "Bob":
109+
- .obj.template.obj.list[name="a"].id
110+
- .obj.template.obj.list[name="a"].key`
111+
if got.Error() != wanted {
112+
t.Errorf("Got %v, wanted %v", got.Error(), wanted)
135113
}
136114
}

0 commit comments

Comments
 (0)