Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: e2e add MapContainsMatchers #352

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/e2e/e2ematcher/matcher.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package e2ematcher

import (
"fmt"

"github.com/hashicorp/go-multierror"
)

Expand Down Expand Up @@ -42,3 +44,11 @@ func Any(ms ...Matcher) Matcher {
return retErr
})
}

func MapContainsMatchers[K comparable, V any](m map[K]V) map[string]any {
matchers := make(map[string]any, len(m))
for k, v := range m {
matchers[fmt.Sprint(k)] = ValidatorEq(v)
}
return matchers
}
7 changes: 1 addition & 6 deletions tests/e2e/envfuncsext/nebulacluster-ready-func.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,7 @@ func isComponentConfigMapExpected(ctx context.Context, cfg *envconf.Config, comp
return false
}

matchers := make(map[string]any, len(componentConfigExpected))
for k, v := range componentConfigExpected {
matchers[k] = e2ematcher.ValidatorEq(v)
}

if err := e2ematcher.Struct(componentConfig, matchers); err != nil {
if err := e2ematcher.Struct(componentConfig, e2ematcher.MapContainsMatchers(componentConfigExpected)); err != nil {
klog.ErrorS(err, "Waiting for NebulaCluster to be ready but ConfigMap not expected",
"namespace", cm.Namespace,
"name", cm.Name,
Expand Down