Skip to content

Commit

Permalink
Merge pull request #19 from nasrul21/refactor-unread-message-response…
Browse files Browse the repository at this point in the history
…-struct

refactor: change unread message count struct name
  • Loading branch information
nasrul21 authored Oct 26, 2022
2 parents 31d4d6d + be47a8a commit 97bb19a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

type Chat interface {
// user
GetUserUnreadMessages(ctx context.Context, params UserUnreadMessagesParams) (UserUnreadMessages, *errors.Error)
GetUserUnreadMessages(ctx context.Context, params UserUnreadMessagesParams) (UserUnreadMessagesResponse, *errors.Error)
GetUserJoinedChannelCount(ctx context.Context, params UserJoinedChannelCountParams) (resp UserJoinedChannelCountResponse, err *errors.Error)
CreateUser(ctx context.Context, request CreateUserRequest) (resp CreateUserResponse, err *errors.Error)

Expand Down
2 changes: 1 addition & 1 deletion chat/chat_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (c *ChatImpl) CreateUser(ctx context.Context, request CreateUserRequest) (r
return
}

func (c *ChatImpl) GetUserUnreadMessages(ctx context.Context, params UserUnreadMessagesParams) (resp UserUnreadMessages, err *errors.Error) {
func (c *ChatImpl) GetUserUnreadMessages(ctx context.Context, params UserUnreadMessagesParams) (resp UserUnreadMessagesResponse, err *errors.Error) {
url := fmt.Sprintf("/v3/users/%s/unread_message_count", params.UserID)
err = c.Client.Call(ctx, http.MethodGet, url, nil, nil, &resp)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions chat/chat_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (m *mockGetUserUnreadMessages) Call(ctx context.Context, method string, url
return args.Get(0).(*errors.Error)
}

result.(*UserUnreadMessages).UnreadCount = 10
result.(*UserUnreadMessagesResponse).UnreadCount = 10

return nil
}
Expand All @@ -38,7 +38,7 @@ func TestGetUserUnreadMessages(t *testing.T) {
name string
args args
setupMock func(m *mockGetUserUnreadMessages)
wantExpected UserUnreadMessages
wantExpected UserUnreadMessagesResponse
wantError *errors.Error
}{
{
Expand All @@ -52,10 +52,10 @@ func TestGetUserUnreadMessages(t *testing.T) {
fmt.Sprintf("/v3/users/%s/unread_message_count", "111001100"),
http.Header(nil),
nil,
&UserUnreadMessages{},
&UserUnreadMessagesResponse{},
).Return(nil)
},
wantExpected: UserUnreadMessages{UnreadCount: 10},
wantExpected: UserUnreadMessagesResponse{UnreadCount: 10},
wantError: nil,
},
{
Expand All @@ -69,7 +69,7 @@ func TestGetUserUnreadMessages(t *testing.T) {
fmt.Sprintf("/v3/users/%s/unread_message_count", "000000000"),
http.Header(nil),
nil,
&UserUnreadMessages{},
&UserUnreadMessagesResponse{},
).Return(errors.FromHTTPErr(400, []byte(`
{
"message": "\"User\" not found.",
Expand All @@ -78,7 +78,7 @@ func TestGetUserUnreadMessages(t *testing.T) {
}
`)))
},
wantExpected: UserUnreadMessages{},
wantExpected: UserUnreadMessagesResponse{},
wantError: errors.FromHTTPErr(400, []byte(`
{
"message": "\"User\" not found.",
Expand Down
2 changes: 1 addition & 1 deletion chat/model_user.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package chat

type UserUnreadMessages struct {
type UserUnreadMessagesResponse struct {
UnreadCount int `json:"unread_count"`
}

Expand Down

0 comments on commit 97bb19a

Please sign in to comment.