Allow to set args from checks

main
Elie 2021-03-30 17:50:13 +02:00
parent 6f39d5c99c
commit 7170f9f09c
1 changed files with 5 additions and 1 deletions

View File

@ -34,6 +34,7 @@ type AccCheck struct {
PreExec func()
PostExec func()
Env map[string]string
Args func() []string
Check func(result *ScanResult, stdout string, err error)
}
@ -349,7 +350,6 @@ func Run(t *testing.T, c AccTestCase) {
"--output", fmt.Sprintf("json://%s", c.getResultFilePath()),
)
}
os.Args = c.Args
for _, check := range c.Checks {
driftctlCmd := cmd.NewDriftctlCmd(test.Build{})
@ -366,6 +366,10 @@ func Run(t *testing.T, c AccTestCase) {
check.PreExec()
c.restoreEnv()
}
os.Args = c.Args
if check.Args != nil {
os.Args = append(os.Args, check.Args()...)
}
_, out, cmdErr := runDriftCtlCmd(driftctlCmd)
if len(check.Env) > 0 {
for key := range check.Env {