Skip to content

Commit

Permalink
Add a haveKeys() helper function to match multiple keys
Browse files Browse the repository at this point in the history
Signed-off-by: Itamar Holder <iholder@redhat.com>
  • Loading branch information
iholder101 committed Jul 19, 2023
1 parent 90c362b commit 81abfca
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/e2e_node/resource_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,18 @@ func boundedSample(lower, upper interface{}) types.GomegaMatcher {
"Histogram": gstruct.Ignore(),
}))
}

func haveKeys(keys ...string) types.GomegaMatcher {
gomega.ExpectWithOffset(1, keys).ToNot(gomega.BeEmpty())
matcher := gomega.HaveKey(keys[0])

if len(keys) == 1 {
return matcher
}

for _, key := range keys[1:] {
matcher = gomega.And(matcher, gomega.HaveKey(key))
}

return matcher
}

0 comments on commit 81abfca

Please sign in to comment.