-
Notifications
You must be signed in to change notification settings - Fork 5.2k
/
consequences.go
47 lines (36 loc) · 1.01 KB
/
consequences.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
44
45
46
47
package project
import (
"context"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/project"
"github.com/argoproj/argo-cd/v2/test/e2e/fixture"
)
// this implements the "then" part of given/when/then
type Consequences struct {
context *Context
actions *Actions
}
func (c *Consequences) Expect() *Consequences {
return c
}
func (c *Consequences) And(block func(app *project.DetailedProjectsResponse, err error)) *Consequences {
c.context.t.Helper()
block(c.detailedProject())
return c
}
func (c *Consequences) detailedProject() (*project.DetailedProjectsResponse, error) {
prj, err := c.get()
return prj, err
}
func (c *Consequences) get() (*project.DetailedProjectsResponse, error) {
_, projectClient, _ := fixture.ArgoCDClientset.NewProjectClient()
prj, err := projectClient.GetDetailedProject(context.Background(), &project.ProjectQuery{
Name: c.context.name,
})
return prj, err
}
func (c *Consequences) Given() *Context {
return c.context
}
func (c *Consequences) When() *Actions {
return c.actions
}