connectClient now returns an error when unsuccessful.

This commit is contained in:
Erik Brakkee 2024-08-24 20:43:20 +02:00
parent 7e062f5777
commit f16d228f6f

View File

@ -149,7 +149,8 @@ func (s *MatchMakerTestSuite) Test_singleAgentAndClient() {
waitForAgentFunc := s.registerAgent(publicId, agent) waitForAgentFunc := s.registerAgent(publicId, agent)
go waitForAgentFunc() go waitForAgentFunc()
client, clientId := s.connectClient(publicId) client, clientId, err := s.connectClient(publicId)
s.Nil(err)
s.checkState(1, 1) s.checkState(1, 1)
@ -167,10 +168,10 @@ func (s *MatchMakerTestSuite) Test_singleAgentAndClient() {
s.checkState(1, 0) s.checkState(1, 0)
} }
func (s *MatchMakerTestSuite) connectClient(publicId models.RendezVousId) (*TestClient, models.ClientId) { func (s *MatchMakerTestSuite) connectClient(publicId models.RendezVousId) (*TestClient, models.ClientId, error) {
client := NewTestClient(s.ctx) client := NewTestClient(s.ctx)
var clientId models.ClientId var clientId models.ClientId
testsupport.RunAndWait( res := testsupport.RunAndWait(
&s.Suite, &s.Suite,
func() any { func() any {
//server //server
@ -181,13 +182,18 @@ func (s *MatchMakerTestSuite) connectClient(publicId models.RendezVousId) (*Test
log.Println("test: synchronizing streams.") log.Println("test: synchronizing streams.")
go synchronizer() go synchronizer()
} }
return nil return err
}, },
func() any { func() any {
// client, nothing to do with wsproxy mode off. // client, nothing to do with wsproxy mode off.
return nil return nil
}) })
return client, clientId
var err error = nil
if res[0] != nil {
err = res[0].(error)
}
return client, clientId, err
} }
func (s *MatchMakerTestSuite) checkState(nAgents int, nClients int) { func (s *MatchMakerTestSuite) checkState(nAgents int, nClients int) {