Skip to content

Commit 6f765d4

Browse files
committed
Merge pull request #4202 from Joshua-Anderson/tests-look-for-warning
fix(tests): abort if warning is found in output
2 parents 941c481 + 886c3ef commit 6f765d4

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

tests/utils/itutils.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,16 @@ func Execute(t *testing.T, cmd string, params interface{}, failFlag bool, expect
295295
}
296296
}
297297
case false:
298-
if _, _, err := RunCommandWithStdoutStderr(cmdl); err != nil {
298+
stdout, stderr, err := RunCommandWithStdoutStderr(cmdl)
299+
if err != nil {
299300
t.Fatal(err)
300-
} else {
301-
fmt.Println("ok")
302301
}
302+
303+
if containsWarning(stdout.String()) || containsWarning(stderr.String()) {
304+
t.Fatal("Warning found in output, aborting")
305+
}
306+
307+
fmt.Println("ok")
303308
}
304309
}
305310

@@ -339,3 +344,11 @@ func GetRandomApp() string {
339344
}
340345
return apps[rand.Intn(len(apps))]
341346
}
347+
348+
func containsWarning(out string) bool {
349+
if strings.Contains(out, "WARNING") {
350+
return true
351+
}
352+
353+
return false
354+
}

0 commit comments

Comments
 (0)