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-974]: Added testcase fore more functions in webhook.go #857

Open
wants to merge 1 commit into
base: MM-956
Choose a base branch
from

Conversation

Kshitij-Katiyar
Copy link
Contributor

Summary

Added testcase for more functions in webhook.go

Original PR

#855

@Kshitij-Katiyar Kshitij-Katiyar added the 2: Dev Review Requires review by a core committer label Nov 28, 2024
@Kshitij-Katiyar Kshitij-Katiyar self-assigned this Nov 28, 2024
Copy link
Member

@wiggin77 wiggin77 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
tc.setup()

Copy link
Contributor

Choose a reason for hiding this comment

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

Add mockAPI.ExpectedCalls = nil

name: "private repo, no permission for author",
event: GetMockPullRequestReviewEvent(actionSubmitted, "approved", MockRepo, true, "authorUser", "reviewerUser"),
setup: func() {
mockKvStore.EXPECT().Get("reviewerUser_githubusername", gomock.Any()).DoAndReturn(func(key string, value interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Create util for return value/func

name: "no subscribed channels for repository",
event: GetMockStarEvent(MockRepo, MockOrg, false, MockSender),
setup: func() {
mockKvStore.EXPECT().Get("subscriptions", gomock.Any()).Return(nil).Times(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace gomock.an() whereever possible

Copy link
Contributor

Choose a reason for hiding this comment

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

we can use anythingOfType instead

setup: func() {
mockKvStore.EXPECT().Get("subscriptions", gomock.Any()).DoAndReturn(func(key string, value interface{}) error {
if v, ok := value.(**Subscriptions); ok {
*v = &Subscriptions{
Copy link
Contributor

Choose a reason for hiding this comment

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

Util for this

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.

3 participants