Skip to content

Commit

Permalink
Fix static call to session GetNumberOfConnectedClients (#431)
Browse files Browse the repository at this point in the history
Co-authored-by: Rodrigo Ueda <rodrigo.ueda@wildlifestudios.com>
  • Loading branch information
rodrigoueda and Rodrigo Ueda authored Dec 19, 2024
1 parent cec30f5 commit de0a7d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion session/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ func CloseAll() {

// GetNumberOfConnectedClients returns the number of connected clients
func GetNumberOfConnectedClients() int64 {
return DefaultSessionPool.GetSessionCount()
return DefaultSessionPool.GetNumberOfConnectedClients()
}
13 changes: 13 additions & 0 deletions session/test/static_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package test

import (
"math"
"testing"

"github.com/golang/mock/gomock"
Expand Down Expand Up @@ -115,3 +116,15 @@ func TestStaticCloseAll(t *testing.T) {
session.DefaultSessionPool = sessionPool
session.CloseAll()
}

func TestGetNumberOfConnectedClients(t *testing.T) {
ctrl := gomock.NewController(t)

expected := int64(math.MaxInt64)
sessionPool := mocks.NewMockSessionPool(ctrl)
sessionPool.EXPECT().GetNumberOfConnectedClients().Return(expected)

session.DefaultSessionPool = sessionPool
numberOfConnections := session.GetNumberOfConnectedClients()
require.Equal(t, expected, numberOfConnections)
}

0 comments on commit de0a7d0

Please sign in to comment.