Fix flaky TestOrphanedResource test (#2210)

This commit is contained in:
Alexander Matyushentsev 2019-08-23 14:11:45 -07:00 committed by GitHub
parent 8b29b9c8c2
commit 608361ce20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -800,9 +800,7 @@ func TestOrphanedResource(t *testing.T) {
Sync().
Then().
Expect(SyncStatusIs(SyncStatusCodeSynced)).
And(func(app *Application) {
assert.Len(t, app.Status.Conditions, 0)
}).
Expect(NoConditions()).
When().
And(func() {
errors.FailOnErr(fixture.KubeClientset.CoreV1().ConfigMaps(fixture.DeploymentNamespace()).Create(&v1.ConfigMap{
@ -824,7 +822,5 @@ func TestOrphanedResource(t *testing.T) {
Refresh(RefreshTypeNormal).
Then().
Expect(SyncStatusIs(SyncStatusCodeSynced)).
And(func(app *Application) {
assert.Len(t, app.Status.Conditions, 0)
})
Expect(NoConditions())
}

View file

@ -62,6 +62,16 @@ func Condition(conditionType ApplicationConditionType, conditionMessage string)
}
}
func NoConditions() Expectation {
return func(c *Consequences) (state, string) {
message := "no conditions"
if len(c.app().Status.Conditions) == 0 {
return succeeded, message
}
return pending, message
}
}
func HealthIs(expected HealthStatusCode) Expectation {
return func(c *Consequences) (state, string) {
actual := c.app().Status.Health.Status