You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/Static/PullRequestProcessingTests.cs
+25-12
Original file line number
Diff line number
Diff line change
@@ -35,12 +35,13 @@ public class PullRequestProcessingTests : ProcessingTestBase
35
35
/// <param name="hasWriteOrAdmin">Whether or not the PR creator has write or admin permissions</param>
// Regardless of whether or not the user has Write or Admin permissions, the prFiles should cause 4 labels to get added
72
-
// which means an issueUpdate will be created
72
+
// Regardless of whether or not the user has Write or Admin permissions, or the PR is created by a BOT, the prFiles should
73
+
// cause 4 labels to get added which means an issueUpdate will be created
73
74
intexpectedUpdates=1;
74
-
75
-
if(hasWriteOrAdmin||isMemberOfOrg)
75
+
if(prCreatedByBot)
76
+
{
77
+
// There should be one update, an IssueUpdate with the PR labels for files in the PR
78
+
Assert.AreEqual(expectedUpdates,totalUpdates,$"The number of updates for a PR created by a BOT user should have been {expectedUpdates} but was instead, {totalUpdates}");
79
+
}
80
+
elseif(hasWriteOrAdmin||isMemberOfOrg)
76
81
{
77
-
// There should be one update, an IssueUpdate with the NoRecentActivity label removed
82
+
// There should be one update, an IssueUpdate with the PR labels for files in the PR
78
83
Assert.AreEqual(expectedUpdates,totalUpdates,$"The number of updates for a user having Write or Admin permission or being a member of Azure org should have been {expectedUpdates} but was instead, {totalUpdates}");
79
84
}
80
85
// If the user doesn't have Write or Admin permissions then "customer-reported" and "Community Contribution" labels
Assert.True(mockGitHubEventClient.GetLabelsToAdd().Contains(label),$"Labels to add should contain {label} which should have been added because of the file paths in the PR but was not.");
93
98
}
94
99
100
+
// If the PR was created by a bot, CustomerReported and CommunityContribution labels and commend should not be added
101
+
if(prCreatedByBot)
102
+
{
103
+
Assert.False(mockGitHubEventClient.GetLabelsToAdd().Contains(TriageLabelConstants.CustomerReported),$"User that created the PR was a BOT, IssueUpdate should not contain {TriageLabelConstants.CustomerReported}.");
104
+
Assert.False(mockGitHubEventClient.GetLabelsToAdd().Contains(TriageLabelConstants.CommunityContribution),$"User that created the PR was a BOT, IssueUpdate should not contain {TriageLabelConstants.CommunityContribution}.");
105
+
Assert.AreEqual(0,mockGitHubEventClient.GetComments().Count,"User that created the PR was a BOT, there should not have been a comment added.");
106
+
107
+
}
95
108
// If the user is not part of the Azure org AND they don't have write or admin collaborator permissions
96
109
// then customer-reported and community-contribution labels should have been added along with a comment
97
-
if(!isMemberOfOrg&&!hasWriteOrAdmin)
110
+
elseif(!isMemberOfOrg&&!hasWriteOrAdmin)
98
111
{
99
112
Assert.True(mockGitHubEventClient.GetLabelsToAdd().Contains(TriageLabelConstants.CustomerReported),$"User does not have write or admin permission, IssueUpdate should contain {TriageLabelConstants.CustomerReported}.");
100
113
Assert.True(mockGitHubEventClient.GetLabelsToAdd().Contains(TriageLabelConstants.CommunityContribution),$"User does not have write or admin permission, IssueUpdate should contain {TriageLabelConstants.CommunityContribution}.");
0 commit comments