Fix length checking for ResMap resources

This commit is contained in:
quiye
2020-05-30 15:17:01 +09:00
parent 144471ce78
commit 08922cfe29
2 changed files with 7 additions and 2 deletions

View File

@@ -532,7 +532,7 @@ func (m *resWrangler) ErrorIfNotEqualSets(other ResMap) error {
for _, r1 := range m.rList {
id := r1.CurId()
others := m2.GetMatchingResourcesByCurrentId(id.Equals)
if len(others) < 0 {
if len(others) == 0 {
return fmt.Errorf(
"id in self missing from other; id: %s", id)
}

View File

@@ -669,7 +669,12 @@ func TestErrorIfNotEqualSets(t *testing.T) {
t.Fatalf("%v should not equal %v %v", m1, m2, err)
}
m3 := resmaptest_test.NewRmBuilder(t, rf).Add(
m3 := resmaptest_test.NewRmBuilder(t, rf).AddR(r2).ResMap()
if err := m2.ErrorIfNotEqualSets(m3); err == nil {
t.Fatalf("%v should not equal %v %v", m2, m3, err)
}
m3 = resmaptest_test.NewRmBuilder(t, rf).Add(
map[string]interface{}{
"apiVersion": "v1",
"kind": "ConfigMap",