add unit tests for oidc.Userinfo
- Add get methods for Address fields to handle nil pointers as we used to
This commit is contained in:
parent
72a108a33b
commit
d41f4b5d21
6 changed files with 52 additions and 5 deletions
|
@ -7,6 +7,26 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestUserInfo_AppendClaims(t *testing.T) {
|
||||
u := new(UserInfo)
|
||||
u.AppendClaims("a", "b")
|
||||
want := map[string]any{"a": "b"}
|
||||
assert.Equal(t, want, u.Claims)
|
||||
|
||||
u.AppendClaims("d", "e")
|
||||
want["d"] = "e"
|
||||
assert.Equal(t, want, u.Claims)
|
||||
}
|
||||
|
||||
func TestUserInfo_GetAddress(t *testing.T) {
|
||||
// nil address
|
||||
u := new(UserInfo)
|
||||
assert.Equal(t, &UserInfoAddress{}, u.GetAddress())
|
||||
|
||||
u.Address = &UserInfoAddress{PostalCode: "1234"}
|
||||
assert.Equal(t, u.Address, u.GetAddress())
|
||||
}
|
||||
|
||||
func TestUserInfoMarshal(t *testing.T) {
|
||||
userinfo := &UserInfo{
|
||||
Subject: "test",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue