From 739556e938d67c84d45e75dafc7d3ea215197904 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Thu, 22 Aug 2024 17:33:54 +0200 Subject: [PATCH] now also testing client removal. --- pkg/server/admin/admin_test.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/server/admin/admin_test.go b/pkg/server/admin/admin_test.go index ec39e5f..15890e6 100644 --- a/pkg/server/admin/admin_test.go +++ b/pkg/server/admin/admin_test.go @@ -190,11 +190,16 @@ func (s *AdminTestSuite) Test_connectClient() { s.Equal(1, len(state.Clients)) s.Equal(clientConn.Info, state.Clients[clientConn.Info.Guid]) - // will close the connections and as a result also th synchronize goroutine. - s.cancelFunc() - - // Note: removing agents and clients after connection loss is the responsibility of the MatchMaker - // Here we only test explicit removal of the agents and clients. + // removing the client will close all connections, we test this by writing to the connections + // after removing the client. + s.admin.RemoveClient(clientConn) + buf := make([]byte, 10) + _, err := clientConn.clientConnection.Write(buf) + s.NotNil(err) + s.True(strings.Contains(err.Error(), "closed")) + _, err = clientConn.agentConnection.Write(buf) + s.NotNil(err) + s.True(strings.Contains(err.Error(), "closed")) } func (s *AdminTestSuite) Test_multipleAgentsAndClients() {