github.com/argoproj/argo-cd/v3@v3.2.1/test/e2e/fixture/admin/actions.go (about) 1 package admin 2 3 import ( 4 "time" 5 6 "github.com/argoproj/argo-cd/v3/test/e2e/fixture" 7 ) 8 9 // this implements the "when" part of given/when/then 10 // 11 // none of the func implement error checks, and that is complete intended, you should check for errors 12 // using the Then() 13 type Actions struct { 14 context *Context 15 lastOutput string 16 lastError error 17 } 18 19 func (a *Actions) prepareExportCommand() []string { 20 a.context.t.Helper() 21 args := []string{"export", "--application-namespaces", fixture.AppNamespace()} 22 23 return args 24 } 25 26 func (a *Actions) prepareImportCommand() []string { 27 a.context.t.Helper() 28 args := []string{"import", "--application-namespaces", fixture.AppNamespace(), "-"} 29 30 return args 31 } 32 33 func (a *Actions) RunExport() *Actions { 34 a.context.t.Helper() 35 a.runCli(a.prepareExportCommand()...) 36 return a 37 } 38 39 func (a *Actions) RunImport(stdin string) *Actions { 40 a.context.t.Helper() 41 a.runCliWithStdin(stdin, a.prepareImportCommand()...) 42 return a 43 } 44 45 func (a *Actions) runCli(args ...string) { 46 a.context.t.Helper() 47 a.lastOutput, a.lastError = RunCli(args...) 48 } 49 50 func (a *Actions) runCliWithStdin(stdin string, args ...string) { 51 a.context.t.Helper() 52 a.lastOutput, a.lastError = RunCliWithStdin(stdin, args...) 53 } 54 55 func (a *Actions) Then() *Consequences { 56 a.context.t.Helper() 57 time.Sleep(fixture.WhenThenSleepInterval) 58 return &Consequences{a.context, a} 59 }