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

Add AssertSubset and AssertNotSubset #34

Closed
Tracked by #27
MarvinJWendt opened this issue Aug 26, 2021 · 5 comments · Fixed by #73
Closed
Tracked by #27

Add AssertSubset and AssertNotSubset #34

MarvinJWendt opened this issue Aug 26, 2021 · 5 comments · Fixed by #73
Assignees
Labels

Comments

@MarvinJWendt
Copy link
Owner

No description provided.

@janisz
Copy link
Contributor

janisz commented Oct 25, 2021

Should we use Equal or EqualValues here?

@MarvinJWendt
Copy link
Owner Author

Hi @janisz, AssertSubset should check if a subset is in a slice.

For example:

sub1 := []string{"Hello",  "World", "How", "Are", "You", "?"}
testza.AssertSubset(t, []string{"How", "Are"}, sub1) // -> Pass
testza.AssertSubset(t, []string{"Hello", "How"}, sub1) // -> Pass
testza.AssertSubset(t, []string{"Hello", "ABCDEF"}, sub1) // -> fail

The method should accept every slice/array.
You can get inspired by testifys assert package: https://github.com/stretchr/testify/blob/ab6dc3262822ed562480c19876b0257ace761e3e/assert/assertions.go#L810

@janisz
Copy link
Contributor

janisz commented Oct 25, 2021

Got it. My question was rather what equality should we use there? Should we compare equality or values?

sub1 := []*A{{a: "A"}, {a: "B"}, {a: "C"}}
testza.AssertSubset(t, []*A{{a: "A"}, {a: "B"}}, sub1) 

@MarvinJWendt
Copy link
Owner Author

sub1 := []*A{{a: "A"}, {a: "B"}, {a: "C"}}
testza.AssertSubset(t, []*A{{a: "A"}, {a: "B"}}, sub1) 

Hi @janisz, that should fail the test :)
In general, with the assertions, you can compare the functionality with testify. To make migration easier, and to fragment the ecosystem less, we try to have similar assertion functionality, if possible.

@MarvinJWendt MarvinJWendt self-assigned this Nov 19, 2021
@github-actions
Copy link

Branch issue-34-Add_AssertSubset_and_AssertNotSubset created!

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

Successfully merging a pull request may close this issue.

2 participants