MCPcopy
hub / github.com/lonng/nano / TestNewDefaultConnectionServer

Function TestNewDefaultConnectionServer

service/default_test.go:7–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5)
6
7func TestNewDefaultConnectionServer(t *testing.T) {
8 service := newDefaultConnectionServer(101024)
9 w := make(chan bool, paraCount)
10 sidChan := make(chan int64, paraCount)
11 for i := 0; i < paraCount; i++ {
12 go func() {
13 service.Increment()
14 w <- true
15 sidChan <- service.SessionID()
16 }()
17 }
18 smap := make(map[int64]struct{}, paraCount)
19 for i := 0; i < paraCount; i++ {
20 <-w
21 sid := <-sidChan
22 if _, ok := smap[sid]; ok {
23 t.Error("wrong session id repeat")
24 } else {
25 smap[sid] = struct{}{}
26 }
27 }
28 if service.Count() != paraCount {
29 t.Error("wrong connection count")
30 }
31}

Callers

nothing calls this directly

Calls 4

IncrementMethod · 0.65
SessionIDMethod · 0.65
CountMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…