mirror of
https://github.com/containers/podman.git
synced 2025-06-26 12:56:45 +08:00
e2e: Add assert-key-is-regex check to quadlet e2e testsuite
We will use this later Signed-off-by: Alexander Larsson <alexl@redhat.com>
This commit is contained in:
@ -117,6 +117,26 @@ func (t *quadletTestcase) assertKeyIs(args []string, unit *parser.UnitFile) bool
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *quadletTestcase) assertKeyIsRegex(args []string, unit *parser.UnitFile) bool {
|
||||
Expect(len(args)).To(BeNumerically(">=", 3))
|
||||
group := args[0]
|
||||
key := args[1]
|
||||
values := args[2:]
|
||||
|
||||
realValues := unit.LookupAll(group, key)
|
||||
if len(realValues) != len(values) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i := range realValues {
|
||||
matched, _ := regexp.MatchString(values[i], realValues[i])
|
||||
if !matched {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *quadletTestcase) assertKeyContains(args []string, unit *parser.UnitFile) bool {
|
||||
Expect(args).To(HaveLen(3))
|
||||
group := args[0]
|
||||
@ -209,6 +229,8 @@ func (t *quadletTestcase) doAssert(check []string, unit *parser.UnitFile, sessio
|
||||
ok = t.assertStdErrContains(args, session)
|
||||
case "assert-key-is":
|
||||
ok = t.assertKeyIs(args, unit)
|
||||
case "assert-key-is-regex":
|
||||
ok = t.assertKeyIsRegex(args, unit)
|
||||
case "assert-key-contains":
|
||||
ok = t.assertKeyContains(args, unit)
|
||||
case "assert-podman-args":
|
||||
|
Reference in New Issue
Block a user