Skip to content

Commit

Permalink
remove TestAuthService_RegisterBOSSession_SessionNotFound
Browse files Browse the repository at this point in the history
SessionManager.AddSession no longer returns a nil value. Remove the unit
test that checks for this behavior.
  • Loading branch information
mk6i committed Jul 8, 2024
1 parent f07c787 commit 5241751
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
27 changes: 0 additions & 27 deletions foodgroup/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -991,33 +991,6 @@ func TestAuthService_RegisterBOSSession_HappyPath(t *testing.T) {
assert.Equal(t, sess, have)
}

func TestAuthService_RegisterBOSSession_SessionNotFound(t *testing.T) {
sess := newTestSession("screen-name")

sessionManager := newMockSessionManager(t)
sessionManager.EXPECT().
AddSession(sess.DisplayScreenName()).
Return(nil)

authCookie := []byte(`the-auth-cookie`)
cookieBaker := newMockCookieBaker(t)

cookieBaker.EXPECT().
Crack(authCookie).
Return([]byte("screen-name"), nil)

userManager := newMockUserManager(t)
userManager.EXPECT().
User(sess.IdentScreenName()).
Return(&state.User{DisplayScreenName: sess.DisplayScreenName()}, nil)

svc := NewAuthService(config.Config{}, sessionManager, nil, userManager, nil, cookieBaker, nil, nil, nil)

have, err := svc.RegisterBOSSession(authCookie)
assert.NoError(t, err)
assert.Nil(t, have)
}

func TestAuthService_RetrieveBOSSession_HappyPath(t *testing.T) {
sess := newTestSession("screen-name")

Expand Down
4 changes: 3 additions & 1 deletion state/session_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ func (s *InMemorySessionManager) maybeRelayMessage(ctx context.Context, msg wire

// AddSession adds a new session to the pool. It replaces an existing session
// with a matching screen name, ensuring that each screen name is unique in the
// pool.
// pool. This method does not return a nil session value. It's possible to add
// a non-existent user to the session. Callers should ensure that the account
// represented by displayScreenName is valid.
func (s *InMemorySessionManager) AddSession(displayScreenName DisplayScreenName) *Session {
s.mapMutex.Lock()
defer s.mapMutex.Unlock()
Expand Down

0 comments on commit 5241751

Please sign in to comment.