mirror of https://github.com/knative/pkg.git
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:
parent
62801f1d34
commit
5ff923b836
|
@ -108,12 +108,12 @@ func (source *Status) ConvertTo(ctx context.Context, sink *Status, predicates ..
|
||||||
|
|
||||||
conditions := make(apis.Conditions, 0, len(source.Conditions))
|
conditions := make(apis.Conditions, 0, len(source.Conditions))
|
||||||
for _, c := range source.Conditions {
|
for _, c := range source.Conditions {
|
||||||
switch c.Type {
|
|
||||||
// Copy over the "happy" condition, which is the only condition that
|
// Copy over the "happy" condition, which is the only condition that
|
||||||
// we can reliably transfer.
|
// we can reliably transfer.
|
||||||
case apis.ConditionReady, apis.ConditionSucceeded:
|
if c.Type == apis.ConditionReady || c.Type == apis.ConditionSucceeded {
|
||||||
conditions = append(conditions, c)
|
conditions = append(conditions, c)
|
||||||
break
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, predicate := range predicates {
|
for _, predicate := range predicates {
|
||||||
|
|
|
@ -137,13 +137,24 @@ func TestConditionSet(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
s2 = &Status{}
|
s2 = &Status{}
|
||||||
s.ConvertTo(context.Background(), s2, func(cond apis.ConditionType) bool {
|
s.ConvertTo(context.Background(), s2,
|
||||||
return cond == "Foo"
|
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() {
|
if !condSet.Manage(s2).IsHappy() {
|
||||||
t.Error("s2.IsHappy() = false, wanted true")
|
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"} {
|
for _, c := range []apis.ConditionType{apis.ConditionReady, "Foo"} {
|
||||||
if cond := mgr.GetCondition(c); cond == nil {
|
if cond := mgr.GetCondition(c); cond == nil {
|
||||||
t.Errorf("GetCondition(%q) = nil, wanted non-nil", c)
|
t.Errorf("GetCondition(%q) = nil, wanted non-nil", c)
|
||||||
|
|
Loading…
Reference in New Issue