push
github
0 of 10 new or added lines in 1 file covered. (0.0%)
40 existing lines in 3 files now uncovered.5132 of 8246 relevant lines covered (62.24%)
0.69 hits per line
| 1 |
package assertions
|
|
| 2 |
|
|
| 3 |
import (
|
|
| 4 |
"sync"
|
|
| 5 |
"testing"
|
|
| 6 |
"time"
|
|
| 7 |
|
|
| 8 |
"github.com/stretchr/testify/assert"
|
|
| 9 |
) |
|
| 10 |
|
|
|
UNCOV
11
|
func ShouldEventuallyReturn(t testing.TB, wg *sync.WaitGroup, timeout time.Duration) {
|
× |
|
UNCOV
12
|
c := make(chan struct{}) |
× |
|
UNCOV
13
|
go func() { |
× |
|
UNCOV
14
|
defer close(c) |
× |
|
UNCOV
15
|
wg.Wait() |
× |
|
UNCOV
16
|
}() |
× |
|
UNCOV
17
|
select {
|
× |
|
UNCOV
18
|
case <-c:
|
× |
|
UNCOV
19
|
return
|
× |
| 20 |
case <-time.After(timeout):
|
× |
| 21 |
assert.Fail(t, "timed out waiting for sync.WaitGroup to finish")
|
× |
| 22 |
} |
|
| 23 |
} |
|
| 24 |
|
|
|
UNCOV
25
|
func ShouldEventuallyClose(t testing.TB, channel chan bool, timeout time.Duration) { |
× |
|
UNCOV
26
|
c := make(chan struct{}) |
× |
|
UNCOV
27
|
select {
|
× |
|
UNCOV
28
|
case <-channel:
|
× |
|
UNCOV
29
|
close(c)
|
× |
|
UNCOV
30
|
return
|
× |
| 31 |
case <-time.After(timeout):
|
× |
| 32 |
assert.Fail(t, "timed out waiting for channel to close")
|
× |
| 33 |
} |
|
| 34 |
} |