Skip to content

Commit 0d0d0c4

Browse files
Enrique Raso BarberoEnrique Raso Barbero
authored andcommitted
Add additional pullrequest prefixes and additional unit test to verify referencenames
1 parent e228cd9 commit 0d0d0c4

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/GitVersion.App.Tests/PullRequestInBuildAgentTest.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ public class PullRequestInBuildAgentTest
1515
{
1616
"refs/pull-requests/5/merge",
1717
"refs/pull/5/merge",
18-
"refs/heads/pull/5/head"
18+
"refs/heads/pull/5/head",
19+
"refs/remotes/pull/5/merge",
20+
"refs/remotes/pull-requests/5/merge"
1921
};
2022

2123
[TestCaseSource(nameof(PrMergeRefs))]
@@ -49,7 +51,6 @@ public async Task VerifyContinuaCIPullRequest(string pullRequestRef)
4951
await VerifyPullRequestVersionIsCalculatedProperly(pullRequestRef, env);
5052
}
5153

52-
5354
[TestCaseSource(nameof(PrMergeRefs))]
5455
public async Task VerifyDronePullRequest(string pullRequestRef)
5556
{
@@ -128,7 +129,6 @@ public async Task VerifyTravisCIPullRequest(string pullRequestRef)
128129
await VerifyPullRequestVersionIsCalculatedProperly(pullRequestRef, env);
129130
}
130131

131-
132132
[TestCaseSource(nameof(PrMergeRefs))]
133133
public async Task VerifyBitBucketPipelinesPullRequest(string pullRequestRef)
134134
{
@@ -180,4 +180,23 @@ private static async Task VerifyPullRequestVersionIsCalculatedProperly(string pu
180180
// Cleanup repository files
181181
DirectoryHelper.DeleteDirectory(remoteRepositoryPath);
182182
}
183+
184+
private static readonly object[] PrMergeRefInputs =
185+
{
186+
new object[] { "refs/pull-requests/5/merge", "refs/pull-requests/5/merge", false, true, false },
187+
new object[] { "refs/pull/5/merge", "refs/pull/5/merge", false, true, false},
188+
new object[] { "refs/heads/pull/5/head", "pull/5/head", true, false, false },
189+
new object[] { "refs/remotes/pull/5/merge", "pull/5/merge", false, true, true },
190+
};
191+
192+
[TestCaseSource(nameof(PrMergeRefInputs))]
193+
public void VerifyPullRequestInput(string pullRequestRef, string friendly, bool isBranch, bool isPullRequest, bool isRemote)
194+
{
195+
var refName = new ReferenceName(pullRequestRef);
196+
197+
Assert.AreEqual(friendly, refName.Friendly);
198+
Assert.AreEqual(isBranch, refName.IsBranch);
199+
Assert.AreEqual(isPullRequest, refName.IsPullRequest);
200+
Assert.AreEqual(isRemote, refName.IsRemoteBranch);
201+
}
183202
}

0 commit comments

Comments
 (0)