You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngs/service/connection_test.go

30 lines
487 B
Go

package service
import "testing"
const paraCount = 500000
func TestNewConnectionService(t *testing.T) {
service := newConnectionService()
w := make(chan bool, paraCount)
for i := 0; i < paraCount; i++ {
go func() {
service.Increment()
service.SessionID()
w <- true
}()
}
for i := 0; i < paraCount; i++ {
<-w
}
if service.Count() != paraCount {
t.Error("wrong connection count")
}
if service.SessionID() != paraCount+1 {
t.Error("wrong session id")
}
}