modification for testability caused a panic when client tries to connect
to unknown agent.
This commit is contained in:
parent
a99de52e56
commit
95204a9f5b
@ -119,7 +119,9 @@ func (converge *MatchMaker) Connect(wsProxyMode bool,
|
|||||||
|
|
||||||
client, err := converge.admin.AddClient(publicId, conn)
|
client, err := converge.admin.AddClient(publicId, conn)
|
||||||
cleanUpFunc := func() {
|
cleanUpFunc := func() {
|
||||||
|
if client != nil {
|
||||||
converge.admin.RemoveClient(client)
|
converge.admin.RemoveClient(client)
|
||||||
|
}
|
||||||
converge.logStatus()
|
converge.logStatus()
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -171,6 +171,14 @@ func (s *MatchMakerTestSuite) Test_singleAgentAndClient() {
|
|||||||
s.checkState(1, 0)
|
s.checkState(1, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *MatchMakerTestSuite) Test_ConnectCLientToUnknownAgent() {
|
||||||
|
publicId := models.RendezVousId("abc")
|
||||||
|
|
||||||
|
client, err := s.connectClient(publicId)
|
||||||
|
s.NotNil(err)
|
||||||
|
s.Nil(client)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *MatchMakerTestSuite) Test_multipleAgentsAndClients() {
|
func (s *MatchMakerTestSuite) Test_multipleAgentsAndClients() {
|
||||||
agents := []string{"abc", "def", "ghi"}
|
agents := []string{"abc", "def", "ghi"}
|
||||||
clients := map[string]int{"abc": 3, "def": 2, "ghi": 5}
|
clients := map[string]int{"abc": 3, "def": 2, "ghi": 5}
|
||||||
@ -232,13 +240,12 @@ func (s *MatchMakerTestSuite) connectClient(publicId models.RendezVousId) (*Test
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
var err error = nil
|
|
||||||
if res[0] != nil {
|
if res[0] != nil {
|
||||||
err = res[0].(error)
|
return nil, res[0].(error)
|
||||||
}
|
}
|
||||||
client.publicId = publicId
|
client.publicId = publicId
|
||||||
client.clientId = clientId
|
client.clientId = clientId
|
||||||
return client, err
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MatchMakerTestSuite) checkState(nAgents int, nClients int) {
|
func (s *MatchMakerTestSuite) checkState(nAgents int, nClients int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user