Skip to content

Commit

Permalink
fix: remove redundant map access (ory#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtam-cybozu authored and shipperizer committed Jan 3, 2024
1 parent f4555cb commit 1169678
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 1169678

Please sign in to comment.