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

support to validate one or more item in slice #209

Closed
vivekbasappa opened this issue Sep 14, 2020 · 1 comment
Closed

support to validate one or more item in slice #209

vivekbasappa opened this issue Sep 14, 2020 · 1 comment

Comments

@vivekbasappa
Copy link

vivekbasappa commented Sep 14, 2020

What would you like to be added:
in the status if we need to validate and assert if some of the items exist in slice. there is no way to validate that. currently assert expects all the items in slice to be provided. example test step fails with "slice length mismatch: 1!= 8"

code kuttl/pkg/test/utils/subset.go
linenumber : 50
function where the change is needed: IsSubset(expected, actual interface{}) error

if reflect.TypeOf(expected).Kind() == reflect.Slice { if reflect.ValueOf(expected).Len() != reflect.ValueOf(actual).Len() { return &SubsetError{ message: fmt.Sprintf("slice length mismatch: %d != %d", reflect.ValueOf(expected).Len(), reflect.ValueOf(actual).Len()), } } for i := 0; i < reflect.ValueOf(expected).Len(); i++ { if err := IsSubset(reflect.ValueOf(expected).Index(i).Interface(), reflect.ValueOf(actual).Index(i).Interface()); err != nil { return err } } }

Why is this needed:
we need a way to assert only given item in the slice . it should not expect all the items in the list. just like we assert fields in status now

@porridge
Copy link
Member

Looks like a duplicate of #76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants