Skip to content

Commit 55cbbf7

Browse files
committed
fix: singledo test
1 parent 664b134 commit 55cbbf7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

common/singledo/singledo_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import (
1111
)
1212

1313
func TestBasic(t *testing.T) {
14-
single := NewSingle[int](time.Millisecond * 30)
14+
t.Parallel()
15+
single := NewSingle[int](time.Millisecond * 200)
1516
foo := 0
1617
shardCount := atomic.NewInt32(0)
1718
call := func() (int, error) {
1819
foo++
19-
time.Sleep(time.Millisecond * 5)
20+
time.Sleep(time.Millisecond * 20)
2021
return 0, nil
2122
}
2223

@@ -39,23 +40,25 @@ func TestBasic(t *testing.T) {
3940
}
4041

4142
func TestTimer(t *testing.T) {
42-
single := NewSingle[int](time.Millisecond * 30)
43+
t.Parallel()
44+
single := NewSingle[int](time.Millisecond * 200)
4345
foo := 0
4446
callM := func() (int, error) {
4547
foo++
4648
return 0, nil
4749
}
4850

4951
_, _, _ = single.Do(callM)
50-
time.Sleep(10 * time.Millisecond)
52+
time.Sleep(100 * time.Millisecond)
5153
_, _, shard := single.Do(callM)
5254

5355
assert.Equal(t, 1, foo)
5456
assert.True(t, shard)
5557
}
5658

5759
func TestReset(t *testing.T) {
58-
single := NewSingle[int](time.Millisecond * 30)
60+
t.Parallel()
61+
single := NewSingle[int](time.Millisecond * 200)
5962
foo := 0
6063
callM := func() (int, error) {
6164
foo++

0 commit comments

Comments
 (0)