mirror of
https://github.com/containers/podman.git
synced 2025-06-29 06:57:13 +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
|
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 {
|
func (t *quadletTestcase) assertKeyContains(args []string, unit *parser.UnitFile) bool {
|
||||||
Expect(args).To(HaveLen(3))
|
Expect(args).To(HaveLen(3))
|
||||||
group := args[0]
|
group := args[0]
|
||||||
@ -209,6 +229,8 @@ func (t *quadletTestcase) doAssert(check []string, unit *parser.UnitFile, sessio
|
|||||||
ok = t.assertStdErrContains(args, session)
|
ok = t.assertStdErrContains(args, session)
|
||||||
case "assert-key-is":
|
case "assert-key-is":
|
||||||
ok = t.assertKeyIs(args, unit)
|
ok = t.assertKeyIs(args, unit)
|
||||||
|
case "assert-key-is-regex":
|
||||||
|
ok = t.assertKeyIsRegex(args, unit)
|
||||||
case "assert-key-contains":
|
case "assert-key-contains":
|
||||||
ok = t.assertKeyContains(args, unit)
|
ok = t.assertKeyContains(args, unit)
|
||||||
case "assert-podman-args":
|
case "assert-podman-args":
|
||||||
|
Reference in New Issue
Block a user