Skip to content

Commit 82097f1

Browse files
committed
colocate never/eventually tests
1 parent 0ee0ec0 commit 82097f1

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

assert/assertions_test.go

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,42 +2970,6 @@ func TestEventuallyWithT_ReturnsTheLatestFinishedConditionErrors(t *testing.T) {
29702970
Len(t, mockT.errors, 2)
29712971
}
29722972

2973-
func TestNeverFalse(t *testing.T) {
2974-
condition := func() bool {
2975-
return false
2976-
}
2977-
2978-
True(t, Never(t, condition, 100*time.Millisecond, 20*time.Millisecond))
2979-
}
2980-
2981-
// TestNeverTrue checks Never with a condition that returns true on second call.
2982-
func TestNeverTrue(t *testing.T) {
2983-
mockT := new(testing.T)
2984-
2985-
// A list of values returned by condition.
2986-
// Channel protects against concurrent access.
2987-
returns := make(chan bool, 2)
2988-
returns <- false
2989-
returns <- true
2990-
defer close(returns)
2991-
2992-
// Will return true on second call.
2993-
condition := func() bool {
2994-
return <-returns
2995-
}
2996-
2997-
False(t, Never(mockT, condition, 100*time.Millisecond, 20*time.Millisecond))
2998-
}
2999-
3000-
func TestNeverFailQuickly(t *testing.T) {
3001-
mockT := new(testing.T)
3002-
3003-
// By making the tick longer than the total duration, we expect that this test would fail if
3004-
// we didn't check the condition before the first tick elapses.
3005-
condition := func() bool { return true }
3006-
False(t, Never(mockT, condition, 100*time.Millisecond, time.Second))
3007-
}
3008-
30092973
// Check that a long running condition doesn't block Eventually.
30102974
// See issue 805 (and its long tail of following issues)
30112975
func TestEventuallyTimeout(t *testing.T) {
@@ -3049,6 +3013,42 @@ func TestEventuallyWithTSucceedQuickly(t *testing.T) {
30493013
True(t, EventuallyWithT(mockT, condition, 100*time.Millisecond, time.Second))
30503014
}
30513015

3016+
func TestNeverFalse(t *testing.T) {
3017+
condition := func() bool {
3018+
return false
3019+
}
3020+
3021+
True(t, Never(t, condition, 100*time.Millisecond, 20*time.Millisecond))
3022+
}
3023+
3024+
// TestNeverTrue checks Never with a condition that returns true on second call.
3025+
func TestNeverTrue(t *testing.T) {
3026+
mockT := new(testing.T)
3027+
3028+
// A list of values returned by condition.
3029+
// Channel protects against concurrent access.
3030+
returns := make(chan bool, 2)
3031+
returns <- false
3032+
returns <- true
3033+
defer close(returns)
3034+
3035+
// Will return true on second call.
3036+
condition := func() bool {
3037+
return <-returns
3038+
}
3039+
3040+
False(t, Never(mockT, condition, 100*time.Millisecond, 20*time.Millisecond))
3041+
}
3042+
3043+
func TestNeverFailQuickly(t *testing.T) {
3044+
mockT := new(testing.T)
3045+
3046+
// By making the tick longer than the total duration, we expect that this test would fail if
3047+
// we didn't check the condition before the first tick elapses.
3048+
condition := func() bool { return true }
3049+
False(t, Never(mockT, condition, 100*time.Millisecond, time.Second))
3050+
}
3051+
30523052
func Test_validateEqualArgs(t *testing.T) {
30533053
if validateEqualArgs(func() {}, func() {}) == nil {
30543054
t.Error("non-nil functions should error")

0 commit comments

Comments
 (0)