mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-06-05 22:44:17 +00:00
23 lines
451 B
Go
23 lines
451 B
Go
package traefikoidc
|
|
|
|
import (
|
|
"sync/atomic"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestAutoCleanupRoutine(t *testing.T) {
|
|
var counter int32
|
|
cleanupFunc := func() {
|
|
atomic.AddInt32(&counter, 1)
|
|
}
|
|
stop := make(chan struct{})
|
|
go autoCleanupRoutine(50*time.Millisecond, stop, cleanupFunc)
|
|
time.Sleep(250 * time.Millisecond)
|
|
close(stop)
|
|
|
|
if atomic.LoadInt32(&counter) < 3 {
|
|
t.Errorf("Expected cleanup to be called at least 3 times, got %d", counter)
|
|
}
|
|
}
|