/
fixture.go
43 lines (31 loc) · 1.12 KB
/
fixture.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package rolloutmanager
import (
"context"
"fmt"
. "github.com/onsi/gomega"
matcher "github.com/onsi/gomega/types"
rolloutsmanagerv1alpha1 "github.com/argoproj-labs/argo-rollouts-manager/api/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/argoproj-labs/argo-rollouts-manager/tests/e2e/fixture"
)
// This is intentionally NOT exported, for now. Create another function in this file/package that calls this function, and export that.
func expectedCondition(f func(app rolloutsmanagerv1alpha1.RolloutManager) bool) matcher.GomegaMatcher {
return WithTransform(func(app rolloutsmanagerv1alpha1.RolloutManager) bool {
k8sClient, err := fixture.GetE2ETestKubeClient()
if err != nil {
fmt.Println(err)
return false
}
err = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(&app), &app)
if err != nil {
fmt.Println(err)
return false
}
return f(app)
}, BeTrue())
}
func HavePhase(phase rolloutsmanagerv1alpha1.RolloutControllerPhase) matcher.GomegaMatcher {
return expectedCondition(func(app rolloutsmanagerv1alpha1.RolloutManager) bool {
return app.Status.Phase == phase
})
}