Skip to content

Commit c8ba67f

Browse files
Introduce assert-has-key assertion
Signed-off-by: Dmitry Konishchev <[email protected]>
1 parent 23057fd commit c8ba67f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/e2e/quadlet_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"path/filepath"
1010
"reflect"
1111
"regexp"
12+
"slices"
1213
"strings"
1314

1415
"github.com/containers/podman/v6/pkg/systemd/parser"
@@ -172,6 +173,16 @@ func (t *quadletTestcase) assertKeyIs(args []string, unit *parser.UnitFile) bool
172173
return true
173174
}
174175

176+
func (t *quadletTestcase) assertHasKey(args []string, unit *parser.UnitFile) bool {
177+
Expect(args).To(HaveLen(3))
178+
group := args[0]
179+
key := args[1]
180+
value := args[2]
181+
182+
realValues := unit.LookupAll(group, key)
183+
return slices.Contains(realValues, value)
184+
}
185+
175186
func (t *quadletTestcase) assertKeyIsEmpty(args []string, unit *parser.UnitFile) bool {
176187
Expect(args).To(HaveLen(2))
177188
group := args[0]
@@ -540,6 +551,8 @@ func (t *quadletTestcase) doAssert(check []string, unit *parser.UnitFile, sessio
540551
ok = t.assertStdErrContains(args, session)
541552
case "assert-key-is":
542553
ok = t.assertKeyIs(args, unit)
554+
case "assert-has-key":
555+
ok = t.assertHasKey(args, unit)
543556
case "assert-key-is-empty":
544557
ok = t.assertKeyIsEmpty(args, unit)
545558
case "assert-key-is-regex":

0 commit comments

Comments
 (0)