conditions were being duplicated since we broke vs. continuing (#1009)

* conditions were being duplicated since we broke vs. continuing

* pr feedback

* butter finger
This commit is contained in:
Dave Protasowski 2020-01-24 10:23:24 -05:00 committed by Knative Prow Robot
parent 62801f1d34
commit 5ff923b836
2 changed files with 17 additions and 6 deletions

View File

@ -108,12 +108,12 @@ func (source *Status) ConvertTo(ctx context.Context, sink *Status, predicates ..
conditions := make(apis.Conditions, 0, len(source.Conditions))
for _, c := range source.Conditions {
switch c.Type {
// Copy over the "happy" condition, which is the only condition that
// we can reliably transfer.
case apis.ConditionReady, apis.ConditionSucceeded:
if c.Type == apis.ConditionReady || c.Type == apis.ConditionSucceeded {
conditions = append(conditions, c)
break
continue
}
for _, predicate := range predicates {

View File

@ -137,13 +137,24 @@ func TestConditionSet(t *testing.T) {
}
s2 = &Status{}
s.ConvertTo(context.Background(), s2, func(cond apis.ConditionType) bool {
return cond == "Foo"
})
s.ConvertTo(context.Background(), s2,
func(cond apis.ConditionType) bool {
return cond == "Foo"
},
func(cond apis.ConditionType) bool {
return cond == "Ready"
},
func(cond apis.ConditionType) bool {
return cond == "Foo"
},
)
if !condSet.Manage(s2).IsHappy() {
t.Error("s2.IsHappy() = false, wanted true")
}
if got, want := len(s2.Conditions), 2; got != want {
t.Errorf("len(s2.Conditions) = %d, wanted %d", got, want)
}
for _, c := range []apis.ConditionType{apis.ConditionReady, "Foo"} {
if cond := mgr.GetCondition(c); cond == nil {
t.Errorf("GetCondition(%q) = nil, wanted non-nil", c)