Files
gitea-mcp/internal/mcp/session_test.go
T
mathiasandClaude Opus 4.8 4c1f36f9eb
CD / Lint / Test / Vet (push) Successful in 7s
CD / Build & Import (push) Successful in 23s
CD / Deploy via GitOps (push) Has been skipped
chore(rename): module gitea.d-ma.be → git.d-ma.be/mathias/gitea-mcp (#39)
Gitea host renamed (infra ADR-0004); the mcp-chassis dep already migrated
(3329ff3), so the sequencing gate is clear. `go mod edit -module` + bulk import
rewrite across all .go files. gitea-mcp is a server binary (not an imported
library), so no downstream consumers break. build + task check green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-03 22:48:26 +02:00

47 lines
808 B
Go

package mcp_test
import (
"sync"
"testing"
"git.d-ma.be/mathias/gitea-mcp/internal/mcp"
"github.com/stretchr/testify/assert"
)
func TestSessionStoreIssueAndCheck(t *testing.T) {
s := mcp.NewSessionStore()
id := s.Issue()
assert.NotEmpty(t, id)
assert.Len(t, id, 32)
assert.True(t, s.Valid(id))
assert.False(t, s.Valid("bogus"))
s.Drop(id)
assert.False(t, s.Valid(id))
}
func TestSessionStoreConcurrency(t *testing.T) {
s := mcp.NewSessionStore()
const goroutines = 32
const perGoroutine = 100
var wg sync.WaitGroup
wg.Add(goroutines)
for i := 0; i < goroutines; i++ {
go func() {
defer wg.Done()
for j := 0; j < perGoroutine; j++ {
id := s.Issue()
if !s.Valid(id) {
t.Errorf("issued id %s reported invalid", id)
}
s.Drop(id)
}
}()
}
wg.Wait()
}