Skip to content

Commit

Permalink
fix test in TestHandlers_GetMe
Browse files Browse the repository at this point in the history
  • Loading branch information
Hueter57 committed Nov 14, 2024
1 parent a0ff91a commit c83bbe0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
14 changes: 7 additions & 7 deletions model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
)

type User struct {
ID uuid.UUID
Name string
DisplayName string
Admin bool
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
ID uuid.UUID `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
Admin bool `json:"admin"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
}

type UserRepository interface {
Expand Down
7 changes: 6 additions & 1 deletion router/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func TestHandlers_GetMe(t *testing.T) {
t.Run("Success", func(t *testing.T) {
t.Parallel()
ctrl := gomock.NewController(t)
accessUser := makeUser(t, false)
accessUser := makeUser(t, random.Numeric(t, 2) == 1)
user := User{
ID: accessUser.ID,
Name: accessUser.Name,
Expand Down Expand Up @@ -321,6 +321,11 @@ func TestHandlers_GetMe(t *testing.T) {
sess.Values[sessionUserKey] = user
require.NoError(t, sess.Save(c.Request(), c.Response()))

h.Repository.MockUserRepository.
EXPECT().
GetUserByID(c.Request().Context(), user.ID).
Return(accessUser, nil)

err = h.Handlers.GetMe(c)
if assert.NoError(t, err) {
assert.Equal(t, http.StatusOK, rec.Code)
Expand Down

0 comments on commit c83bbe0

Please sign in to comment.