44 lines
588 B
Go
44 lines
588 B
Go
package oauth
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestSessionStore_Stop_Idempotent(t *testing.T) {
|
|
store := NewSessionStore()
|
|
|
|
store.Stop()
|
|
store.Stop()
|
|
|
|
select {
|
|
case <-store.stopCh:
|
|
// ok
|
|
case <-time.After(time.Second):
|
|
t.Fatal("stopCh 未关闭")
|
|
}
|
|
}
|
|
|
|
func TestSessionStore_Stop_Concurrent(t *testing.T) {
|
|
store := NewSessionStore()
|
|
|
|
var wg sync.WaitGroup
|
|
for range 50 {
|
|
wg.Add(1)
|
|
go func() {
|
|
defer wg.Done()
|
|
store.Stop()
|
|
}()
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
select {
|
|
case <-store.stopCh:
|
|
// ok
|
|
case <-time.After(time.Second):
|
|
t.Fatal("stopCh 未关闭")
|
|
}
|
|
}
|