Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 78 additions & 6 deletions server/plugin/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const (
MockChannelID = "mockChannelID"
MockCreatorID = "mockCreatorID"
MockBotID = "mockBotID"
MockOrg = "mockOrg"
MockSender = "mockSender"
MockPostMessage = "mockPostMessage"
MockOrgRepo = "mockOrg/mockRepo"
MockHead = "mockHead"
Expand Down Expand Up @@ -256,22 +258,25 @@ func GetMockDeleteEventWithInvalidType() *github.DeleteEvent {
}
}

func GetMockPullRequestReviewEvent(action, state string) *github.PullRequestReviewEvent {
func GetMockPullRequestReviewEvent(action, state, repo string, isPrivate bool, reviewer, author string) *github.PullRequestReviewEvent {
return &github.PullRequestReviewEvent{
Action: github.String(action),
Repo: &github.Repository{
Name: github.String(MockRepoName),
Name: github.String(repo),
FullName: github.String(MockOrgRepo),
Private: github.Bool(false),
Private: github.Bool(isPrivate),
HTMLURL: github.String(fmt.Sprintf("%s%s", GithubBaseURL, MockOrgRepo)),
},
Sender: &github.User{Login: github.String(reviewer)},
Review: &github.PullRequestReview{
User: &github.User{
Login: github.String(reviewer),
},
State: github.String(state),
},
Sender: &github.User{
Login: github.String(MockUserLogin),
PullRequest: &github.PullRequest{
User: &github.User{Login: github.String(author)},
},
PullRequest: &github.PullRequest{},
}
}

Expand Down Expand Up @@ -369,3 +374,70 @@ func GetMockPullRequestEvent(action, repoName string, isPrivate bool, sender, us
RequestedReviewer: &github.User{Login: github.String(user)},
}
}

func GetMockIssuesEvent(action, repoName string, isPrivate bool, author, sender, assignee string) *github.IssuesEvent {
return &github.IssuesEvent{
Action: &action,
Repo: &github.Repository{FullName: &repoName, Private: &isPrivate},
Issue: &github.Issue{User: &github.User{Login: &author}},
Sender: &github.User{Login: &sender},
Assignee: func() *github.User {
if assignee == "" {
return nil
}
return &github.User{Login: &assignee}
}(),
}
}

func GetMockStarEvent(repo, org string, isPrivate bool, sender string) *github.StarEvent {
return &github.StarEvent{
Repo: &github.Repository{
Name: github.String(repo),
Private: github.Bool(isPrivate),
FullName: github.String(fmt.Sprintf("%s/%s", repo, org)),
},
Sender: &github.User{Login: github.String(sender)},
}
}

func GetMockReleaseEvent(repo, org, action, sender string) *github.ReleaseEvent {
return &github.ReleaseEvent{
Action: &action,
Repo: &github.Repository{
Name: github.String(repo),
Owner: &github.User{Login: github.String(org)},
FullName: github.String(fmt.Sprintf("%s/%s", repo, org)),
},
Sender: &github.User{Login: github.String(sender)},
}
}

func GetMockDiscussionEvent(repo, org, sender string) *github.DiscussionEvent {
return &github.DiscussionEvent{
Repo: &github.Repository{
Name: github.String(repo),
Owner: &github.User{Login: github.String(org)},
FullName: github.String(fmt.Sprintf("%s/%s", repo, org)),
},
Sender: &github.User{Login: github.String(sender)},
Discussion: &github.Discussion{
Number: github.Int(123),
},
}
}

func GetMockDiscussionCommentEvent(repo, org, action, sender string) *github.DiscussionCommentEvent {
return &github.DiscussionCommentEvent{
Action: &action,
Repo: &github.Repository{
Name: github.String(repo),
Owner: &github.User{Login: github.String(org)},
FullName: github.String(fmt.Sprintf("%s/%s", repo, org)),
},
Sender: &github.User{Login: github.String(sender)},
Comment: &github.CommentDiscussion{
ID: github.Int64(456),
},
}
}
Loading