sync: migrate ai-operator to Gitea (2026-08-10)

This commit is contained in:
konturai-ops
2026-08-10 15:26:52 +00:00
commit 53652b95ad
173 changed files with 16676 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
package call
import (
"fmt"
"sync"
"testing"
"time"
)
func TestSessionStoreCreateGetDelete(t *testing.T) {
store := NewSessionStore()
store.Create(&CallSession{AsteriskChannelID: "c1"})
if store.Count() != 1 {
t.Fatalf("count=%d", store.Count())
}
if _, ok := store.Get("c1"); !ok {
t.Fatal("missing c1")
}
store.Delete("missing")
store.Delete("c1")
if store.Count() != 0 {
t.Fatalf("count=%d", store.Count())
}
}
func TestSessionStoreConcurrent(t *testing.T) {
store := NewSessionStore()
var wg sync.WaitGroup
for i := 0; i < 50; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
id := fmt.Sprintf("c%d", i)
store.Create(&CallSession{AsteriskChannelID: id, StartedAt: time.Now()})
_, _ = store.Get(id)
}(i)
}
wg.Wait()
if store.Count() != 50 {
t.Fatalf("count=%d", store.Count())
}
}