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

assert: fix TestEventuallyTimeout #1412

Merged
merged 3 commits into from Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions assert/assertions_test.go
Expand Up @@ -2869,12 +2869,26 @@ func TestNeverTrue(t *testing.T) {
False(t, Never(mockT, condition, 100*time.Millisecond, 20*time.Millisecond))
}

func TestEventuallyIssue805(t *testing.T) {
// Check that a long running condition doesn't block Eventually.
// See issue 805 (and its long tail of following issues)
func TestEventuallyTimeout(t *testing.T) {
mockT := new(testing.T)

NotPanics(t, func() {
condition := func() bool { <-time.After(time.Millisecond); return true }
done, done2 := make(chan struct{}), make(chan struct{})

// A condition function that returns after the Eventually timeout
condition := func() bool {
// Wait until Eventually times out and terminates
<-done
close(done2)
return true
}

False(t, Eventually(mockT, condition, time.Millisecond, time.Microsecond))

close(done)
<-done2
})
}

Expand Down