Пример #1
0
 public void WhenReviewStatusIsUpdated_ThenSendMessage()
 {
     ActionTestBuilder <ReviewStatusAction>
     .Create((slack, logger) => new ReviewStatusAction(slack, logger))
     .ExecuteWith("reviewSubmit.json", slackChannels: "#general")
     .AssertInvokedOn(requestType: "pull_request_review")
     .AssertSlackJsonTypeIs("review_status")
     .Assert(slack =>
             slack.Received(1).Send(Arg.Is <string>("#general"), Arg.Any <SlackMessageModel>()));
 }
Пример #2
0
 public void WhenPullRequestIsReadyForReview_ThenSendMessage()
 {
     ActionTestBuilder <PullRequestForReviewAction>
     .Create((slack, logger) => new PullRequestForReviewAction(slack, logger))
     .ExecuteWith("pullRequestForReview.json", slackChannels: "#general")
     .AssertSlackJsonTypeIs("ready_for_review")
     .AssertInvokedOn(requestType: "pull_request")
     .Assert(slack =>
             slack.Received(1).Send(Arg.Is <string>("#general"), Arg.Any <SlackMessageModel>()));
 }
Пример #3
0
 public void WhenReviewIsRequestedFromTeam_ThenSendMessageWithTeamInformation()
 {
     ActionTestBuilder <ReviewRequestAction>
     .Create((slack, logger) => new ReviewRequestAction(slack, logger))
     .ExecuteWith("review_request_from_team.json", slackChannels: "#general")
     .AssertInvokedOn(requestType: "pull_request")
     .AssertSlackJsonTypeIs("review_request")
     .Assert(slack =>
             slack.Received(1).Send(Arg.Is("#general"), Arg.Is <SlackMessageModel>(x => x.Text.Contains("test-team"))));
 }
Пример #4
0
 public void WhenNewPublicRepoIsCreated_ThenSendMessage()
 {
     ActionTestBuilder <NewRepoAction>
     .Create((slack, logger) => new NewRepoAction(slack, logger))
     .ExecuteWith("createPublicRepo.json", slackChannels: "#general")
     .AssertSlackJsonTypeIs("new_repository")
     .AssertInvokedOn(requestType: "repository")
     .Assert(slack =>
             slack.Received(1).Send(Arg.Is <string>("#general"), Arg.Is <SlackMessageModel>(x => x.Title.Contains("public"))));
 }
Пример #5
0
 public void WhenNewReleaseIsCreated_ThenSendMessage()
 {
     ActionTestBuilder <NewReleaseAction>
     .Create((slack, logger) => new NewReleaseAction(slack, logger))
     .ExecuteWith("newRelease.json", slackChannels: "#general")
     .AssertSlackJsonTypeIs("new_release")
     .AssertInvokedOn(requestType: "release")
     .Assert(slack =>
             slack.Received(1).Send(Arg.Is <string>("#general"), Arg.Any <SlackMessageModel>()));
 }
Пример #6
0
 public void WhenPullRequestIsClosedButNotMerged_ThenSendMessageAboutAction()
 {
     ActionTestBuilder <PullRequestClosedAction>
     .Create((slack, logger) => new PullRequestClosedAction(slack, logger))
     .ExecuteWith("pullRequestNotMerged.json", slackChannels: "#general")
     .AssertInvokedOn(requestType: "pull_request")
     .AssertSlackJsonTypeIs("pull_request")
     .Assert(slack =>
             slack.Received(1).Send(Arg.Is("#general"), Arg.Is <SlackMessageModel>(x => x.Color == "danger" && x.Title.Contains("closed"))));
 }
Пример #7
0
 public void WhenVulnerabilityAlertIsResolved_ThenSendMessage()
 {
     ActionTestBuilder <VulnerabilityAlertAction>
     .Create((slack, logger) => new VulnerabilityAlertAction(slack, logger))
     .ExecuteWith("vulnerabilityAlert.resolve.json", slackChannels: "#general")
     .AssertInvokedOn(requestType: "repository_vulnerability_alert")
     .AssertSlackJsonTypeIs("repository_vulnerability_alert")
     .Assert(slack =>
             slack.Received(1).Send(Arg.Is <string>("#general"), Arg.Any <SlackMessageModel>()));
 }
Пример #8
0
 public void WhenJenkinsBuildFails_ThenSendMessage()
 {
     ActionTestBuilder <JenkinsBuildFailAction>
     .Create((slack, logger) => new JenkinsBuildFailAction(slack, logger))
     .ExecuteWith("jenkinsBuildFailure.json", slackChannels: "#general")
     .AssertInvokedOn(requestType: "status")
     .AssertSlackJsonTypeIs("jenkins_build_error")
     .Assert(slack =>
             slack.Received(1).Send(Arg.Is("#general"), Arg.Any <SlackMessageModel>()));
 }
Пример #9
0
 public void WhenNewLabelIsAddedToPullRequest_ThenSendMessage()
 {
     ActionTestBuilder <NewLabelPullRequestAction>
     .Create((slack, logger) => new NewLabelPullRequestAction(slack, logger))
     .ExecuteWith("pullRequestLabeled.json", slackChannels: "#general")
     .AssertInvokedOn(requestType: "pull_request")
     .AssertSlackJsonTypeIs("pullrequest_label")
     .Assert(slack =>
             slack.Received(1).Send(Arg.Is <string>("#general"), Arg.Any <SlackMessageModel>()));
 }
Пример #10
0
 public void WhenNewLabelIsAddedToPullRequestButLabelNameIsFiltered_ThenDontSendMessage()
 {
     ActionTestBuilder <NewLabelPullRequestAction>
     .Create((slack, logger) => new NewLabelPullRequestAction(slack, logger))
     .ExecuteWith("pullRequestLabeled.json", new SlackActionModel
     {
         Type    = "pullrequest_label",
         Enabled = true,
         Channel = "#general",
         Data    = new JArray("this_doesnt_match")
     })
     .Assert(slack =>
             slack.DidNotReceive().Send(Arg.Any <string>(), Arg.Any <SlackMessageModel>()));
 }