Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-823]: Added testcase for post.go #138

Open
wants to merge 8 commits into
base: MM-822
Choose a base branch
from
Open

Conversation

Kshitij-Katiyar
Copy link
Contributor

Summary

Added testcase for server/post.go

@Kshitij-Katiyar Kshitij-Katiyar added the 2: Dev Review Requires review by a core committer label Oct 10, 2024
@Kshitij-Katiyar Kshitij-Katiyar self-assigned this Oct 10, 2024
api.On("HasPermissionToChannel", "testUserID", "testChannelID", model.PermissionCreatePost).Return(true)
api.On("GetChannel", "testChannelID").Return(&model.Channel{Id: "testChannelID", Type: model.ChannelTypeDirect}, nil)
api.On("GetChannelMembers", "testChannelID", 0, 100).Return(model.ChannelMembers{}, nil)
api.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating the post"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's stay typesafe for these tests.

mockPost := mock.AnythingOfType("*model.Post")

then

api.On("CreatePost", mockPost).Return(nil, &model.AppError{Message: "error creating the post"})

Do this for all instances.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kshitij-Katiyar I'm still seeing mock.Anything in a number of places. Can you make these type-safe?

api.On("HasPermissionToChannel", "testUserID", "testChannelID", model.PermissionCreatePost).Return(true)
api.On("GetChannel", "testChannelID").Return(&model.Channel{Id: "testChannelID", Type: model.ChannelTypeDirect}, nil)
api.On("GetChannelMembers", "testChannelID", 0, 100).Return(model.ChannelMembers{}, nil)
api.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating the post"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kshitij-Katiyar I'm still seeing mock.Anything in a number of places. Can you make these type-safe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core committer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants