Skip to content

Conversation

@dylanlott
Copy link
Contributor

Description

Adds tests for snapshot atomicity and iteration.

Quick checks:

  • I have followed the Code Guidelines.
  • There is no other pull request for the same update/change.
  • I have written unit tests.
  • I have made sure that the PR is of reasonable size and can be easily reviewed.

@lovromazgon
Copy link
Contributor

Tests are looking nice already! 👍

Base automatically changed from dylan/teardown to main April 8, 2022 18:14
@dylanlott dylanlott marked this pull request as ready for review April 8, 2022 18:25
@dylanlott dylanlott requested a review from a team as a code owner April 8, 2022 18:25
Copy link
Contributor

@lovromazgon lovromazgon left a comment

Choose a reason for hiding this comment

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

Approving already to not block this further, but I'd appreciate it if subtests were split into normal tests. Looking good otherwise 👍

now := time.Now()
rec, err := s.Next(ctx)
is.NoErr(err)
func TestSnapshot(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The three subtest in this test have nothing in common except the connection pool, IMO we should keep it simple and split them back into regular tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I slightly disagree, they all test constraints of the snapshot's lifecycle, but I factored them back out to their own tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify what I meant - they have no setup or cleanup in common, they are pretty much independent of each other, that's why I think they should be separate tests (that also makes it easier to run each one separately). The fact that they are in this file already indicates that they test the snapshot iterator, no need to further group IMO. I would probably go with a subtest if there were some substantial setup/cleanup that we don't want to repeat for each test, or for table-driven tests.

rec, err := s.Next(ctx)
is.NoErr(err)
func TestSnapshot(t *testing.T) {
is := is.New(t)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sidenote: watch out, using the same is instance in subtests means that once the first subtest fails the whole test will stop and no other subtests will even be run. It would be better to call is.New for each subtest. That said, this won't be a problem if we split the subtests into separate tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's good to know 👍 Thanks!

@dylanlott dylanlott merged commit c1eddf8 into main Apr 12, 2022
@dylanlott dylanlott deleted the dylan/test-iteration branch April 12, 2022 19:52
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.

4 participants