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

testutils: add require library #9

Merged
merged 1 commit into from
Nov 11, 2024
Merged

Conversation

RaduBerinde
Copy link
Member

@RaduBerinde RaduBerinde commented Nov 9, 2024

See doc.go for description.

Add a library inspired by github.com/stretchr/testify/require but
with simpler implementation and using generics. The benefit of
generics is that we don't have to cast constants, e.g.
require.Equal(t, a, uint32(2))).

We also have some additional assertions around channel receive and
function error argument unwrapping.


This change is Reviewable

See doc.go for description.

Add a library inspired by `github.com/stretchr/testify/require` but
with simpler implementation and using generics. The benefit of
generics is that we don't have to cast constants, e.g.
`require.Equal(t, a, uint32(2))`).

We also have some additional assertions around channel receive and
function error argument unwrapping.
@RaduBerinde RaduBerinde requested a review from jbowens November 9, 2024 20:17
Copy link
Contributor

@jbowens jbowens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 12 of 12 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @RaduBerinde)


testutils/require/errors.go line 22 at r1 (raw file):

func NoError(tb TB, err error) {
	if err != nil {
		tb.Helper()

I like the change to move tb.Helper() into the error case so we can use it in benchmarks too


testutils/require/errors.go line 41 at r1 (raw file):

//
//	v := require.NoError1(SomeFunc())
func NoError1[T any](a T, err error) T {

good idea

@RaduBerinde
Copy link
Member Author

TFTR!

@RaduBerinde RaduBerinde merged commit 822e734 into cockroachdb:main Nov 11, 2024
6 of 7 checks passed
@RaduBerinde RaduBerinde deleted the require branch November 11, 2024 16:55
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

Successfully merging this pull request may close these issues.

2 participants