(t *testing.T)
| 5 | ) |
| 6 | |
| 7 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…