mirror of
https://github.com/MetaCubeX/Clash.Meta.git
synced 2025-04-19 08:40:57 +00:00
fix: singledo test
This commit is contained in:
parent
664b134015
commit
55cbbf7f41
1 changed files with 8 additions and 5 deletions
|
@ -11,12 +11,13 @@ import (
|
|||
)
|
||||
|
||||
func TestBasic(t *testing.T) {
|
||||
single := NewSingle[int](time.Millisecond * 30)
|
||||
t.Parallel()
|
||||
single := NewSingle[int](time.Millisecond * 200)
|
||||
foo := 0
|
||||
shardCount := atomic.NewInt32(0)
|
||||
call := func() (int, error) {
|
||||
foo++
|
||||
time.Sleep(time.Millisecond * 5)
|
||||
time.Sleep(time.Millisecond * 20)
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
|
@ -39,7 +40,8 @@ func TestBasic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestTimer(t *testing.T) {
|
||||
single := NewSingle[int](time.Millisecond * 30)
|
||||
t.Parallel()
|
||||
single := NewSingle[int](time.Millisecond * 200)
|
||||
foo := 0
|
||||
callM := func() (int, error) {
|
||||
foo++
|
||||
|
@ -47,7 +49,7 @@ func TestTimer(t *testing.T) {
|
|||
}
|
||||
|
||||
_, _, _ = single.Do(callM)
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
_, _, shard := single.Do(callM)
|
||||
|
||||
assert.Equal(t, 1, foo)
|
||||
|
@ -55,7 +57,8 @@ func TestTimer(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestReset(t *testing.T) {
|
||||
single := NewSingle[int](time.Millisecond * 30)
|
||||
t.Parallel()
|
||||
single := NewSingle[int](time.Millisecond * 200)
|
||||
foo := 0
|
||||
callM := func() (int, error) {
|
||||
foo++
|
||||
|
|
Loading…
Add table
Reference in a new issue