From 11696788275cf9a9d5fc7d5b58c4812c133b2156 Mon Sep 17 00:00:00 2001 From: dtam-cybozu Date: Mon, 13 Nov 2023 21:51:21 +0900 Subject: [PATCH] fix: remove redundant map access (#775) --- session.go | 3 --- session_test.go | 8 ++++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/session.go b/session.go index 10d856924..9c810cd9a 100644 --- a/session.go +++ b/session.go @@ -52,9 +52,6 @@ func (s *DefaultSession) GetExpiresAt(key TokenType) time.Time { s.ExpiresAt = make(map[TokenType]time.Time) } - if _, ok := s.ExpiresAt[key]; !ok { - return time.Time{} - } return s.ExpiresAt[key] } diff --git a/session_test.go b/session_test.go index 0a4a85b8e..a3e1ac17d 100644 --- a/session_test.go +++ b/session_test.go @@ -15,3 +15,11 @@ func TestSession(t *testing.T) { assert.Empty(t, s.GetUsername()) assert.Nil(t, s.Clone()) } + +func TestZeroSession(t *testing.T) { + var s *DefaultSession = new(DefaultSession) + assert.Empty(t, s.GetSubject()) + assert.Empty(t, s.GetUsername()) + assert.Empty(t, s.Clone()) + assert.Empty(t, s.GetExpiresAt(AccessToken)) +}