P0 fixes: - ModelError.Is(): use exact matching instead of substring contains() - shouldClearStickySession: add context param for cancellation/tracing P1 fixes: - TODO stubs: return 501 Not Implemented errors - validateInstanceSignature: deduplicate to shared validateCodeSignature() - Error messages: standardize to English only - http.go: remove pseudo if-else with duplicate branches
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 未关闭")
|
|
}
|
|
}
|