(t *testing.T)
| 198 | } |
| 199 | |
| 200 | func TestCreateSessionPrunesUserSessionLimit(t *testing.T) { |
| 201 | srv := newTestServer(nil) |
| 202 | var firstSessionID string |
| 203 | for i := range maxUserSessions { |
| 204 | currentSession := srv.createSession(1) |
| 205 | if i == 0 { |
| 206 | firstSessionID = currentSession.id |
| 207 | } |
| 208 | } |
| 209 | srv.createSession(2) |
| 210 | srv.createSession(1) |
| 211 | |
| 212 | if _, ok := srv.sessions[firstSessionID]; ok { |
| 213 | t.Fatal("expected oldest user session to be pruned") |
| 214 | } |
| 215 | if got := countSessionsForUser(srv, 1); got != maxUserSessions { |
| 216 | t.Fatalf("unexpected user session count: got %d want %d", got, maxUserSessions) |
| 217 | } |
| 218 | if got := len(srv.sessions); got != maxUserSessions+1 { |
| 219 | t.Fatalf("unexpected total session count: got %d want %d", got, maxUserSessions+1) |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | func TestCreateSessionPrunesGlobalSessionLimit(t *testing.T) { |
| 224 | srv := newTestServer(nil) |
nothing calls this directly
no test coverage detected