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

Test com.Cond #46

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Test com.Cond #46

wants to merge 2 commits into from

Conversation

Al2Klimov
Copy link
Member

No description provided.

@Al2Klimov Al2Klimov added enhancement New feature or request tests Adding tests to existing code labels Jul 19, 2024
@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Jul 19, 2024
@Al2Klimov Al2Klimov removed the enhancement New feature or request label Jul 19, 2024
Comment on lines +28 to +31
case <-done:
require.Fail(t, "cond should still not be closed")
case <-cond.Done():
require.Fail(t, "cond should not be closed for round 2, yet")
Copy link
Member

Choose a reason for hiding this comment

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

Is there a difference between those two cases? Both cases check the value of cond.Done(), returning cond.done which doesn't change over the time. Unless I'm missing something, this is the exact same channel.

Copy link
Member Author

Choose a reason for hiding this comment

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

What you digged out is an implementation detail which tests don't rely on.

done := cond.Done()
wait := cond.Wait()

require.NoError(t, cond.Close())
Copy link
Member

Choose a reason for hiding this comment

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

In its current implementation, Close() always returns nil, even when the API doc states otherwise.

Comment on lines +63 to +70
select {
case _, ok := <-cond.Done():
if ok {
require.Fail(t, "new cond-closed channel should be closed")
}
case <-time.After(time.Second / 10):
require.Fail(t, "cond should be still closed")
}
Copy link
Member

Choose a reason for hiding this comment

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

Again, same .done channel as already checked in the select above.

Copy link
Member Author

Choose a reason for hiding this comment

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

What you digged out is an implementation detail which tests don't rely on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed CLA is signed by all contributors of a PR tests Adding tests to existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants