responseRecorder = *context.ResponseRecorder pullRequests = *context.PullRequests }) headers.Is(func() map[string]string { return map[string]string{ "X-Github-Event": "issue_comment", } }) requestJSON.Is(func() string { return IssueCommentEvent("!squash") }) Context("with GitHub request failing", func() { BeforeEach(func() { pullRequests. On("Get", repositoryOwner, repositoryName, issueNumber). Return(nil, nil, errors.New("an error")) }) It("fails with a gateway error", func() { handle() Expect(responseRecorder.Code).To(Equal(http.StatusBadGateway)) }) }) Context("with GitHub request succeeding", func() { pr := &github.PullRequest{ Base: &github.PullRequestBranch{ SHA: github.String("1234"), Ref: github.String("master"), Repo: repository,
It("fails with a gateway error", func() { handle() Expect(responseRecorder.Code).To(Equal(http.StatusBadGateway)) }) }) Context("with github request to add the label succeeding", func() { BeforeEach(func() { issues. On("AddLabelsToIssue", repositoryOwner, repositoryName, issueNumber, []string{grh.MergingLabel}). Return(nil, nil, nil) }) Context("with fetching the PR failing", func() { BeforeEach(func() { pullRequests. On("Get", repositoryOwner, repositoryName, issueNumber). Return(nil, nil, errors.New("an error")) }) It("fails with a gateway error", func() { handle() Expect(responseRecorder.Code).To(Equal(http.StatusBadGateway)) }) }) Context("with the PR being already merged", func() { BeforeEach(func() { pullRequests. On("Get", repositoryOwner, repositoryName, issueNumber). Return(&github.PullRequest{ Merged: github.Bool(true),