Skip to content

Commit

Permalink
fix: remove redundant map access (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtam-cybozu authored Nov 13, 2023
1 parent 44fd2cc commit dfa2c0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 0 additions & 3 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down
8 changes: 8 additions & 0 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

0 comments on commit dfa2c0a

Please sign in to comment.