mirror of
https://github.com/containers/podman.git
synced 2025-11-29 01:28:22 +08:00
Introduce assert-has-key assertion
Signed-off-by: Dmitry Konishchev <konishchev@gmail.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/podman/v6/pkg/systemd/parser"
|
||||
@@ -172,6 +173,16 @@ func (t *quadletTestcase) assertKeyIs(args []string, unit *parser.UnitFile) bool
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *quadletTestcase) assertHasKey(args []string, unit *parser.UnitFile) bool {
|
||||
Expect(args).To(HaveLen(3))
|
||||
group := args[0]
|
||||
key := args[1]
|
||||
value := args[2]
|
||||
|
||||
realValues := unit.LookupAll(group, key)
|
||||
return slices.Contains(realValues, value)
|
||||
}
|
||||
|
||||
func (t *quadletTestcase) assertKeyIsEmpty(args []string, unit *parser.UnitFile) bool {
|
||||
Expect(args).To(HaveLen(2))
|
||||
group := args[0]
|
||||
@@ -540,6 +551,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-has-key":
|
||||
ok = t.assertHasKey(args, unit)
|
||||
case "assert-key-is-empty":
|
||||
ok = t.assertKeyIsEmpty(args, unit)
|
||||
case "assert-key-is-regex":
|
||||
|
||||
Reference in New Issue
Block a user