quadlet tests: Run the tests even for (exected) failed tests

Otherwise the noimage test doesn't look at the stderr assertion.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
This commit is contained in:
Alexander Larsson 2022-10-20 09:22:32 +02:00
parent 8d41c7d2eb
commit 0de98b1b6c
1 changed files with 14 additions and 5 deletions

View File

@ -174,7 +174,10 @@ func (t *quadletTestcase) doAssert(check []string, unit *parser.UnitFile, sessio
}
if !ok {
s, _ := unit.ToString()
s := "(nil)"
if unit != nil {
s, _ = unit.ToString()
}
return fmt.Errorf("Failed assertion for %s: %s\n\n%s", t.serviceName, strings.Join(check, " "), s)
}
return nil
@ -189,12 +192,18 @@ func (t *quadletTestcase) check(generateDir string, session *PodmanSessionIntegr
}
file := filepath.Join(generateDir, t.serviceName)
if _, err := os.Stat(file); os.IsNotExist(err) && expectFail {
return // Successful fail
_, err := os.Stat(file)
if expectFail {
Expect(err).To(MatchError(os.ErrNotExist))
} else {
Expect(err).ToNot(HaveOccurred())
}
unit, err := parser.ParseUnitFile(file)
Expect(err).To(BeNil())
var unit *parser.UnitFile
if !expectFail {
unit, err = parser.ParseUnitFile(file)
Expect(err).To(BeNil())
}
for _, check := range t.checks {
err := t.doAssert(check, unit, session)