Skip to content

Commit c0e65e3

Browse files
committed
Add integration tests: Given a main branch with three commits
1 parent ee1afca commit c0e65e3

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using GitVersion.Configuration;
2+
using GitVersion.Core.Tests;
3+
using GitVersion.Core.Tests.IntegrationTests;
4+
using GitVersion.VersionCalculation;
5+
6+
namespace GitVersion.Core.TrunkBased;
7+
8+
internal partial class TrunkBasedScenariosWithAGitHubFlow
9+
{
10+
[Parallelizable(ParallelScope.All)]
11+
public class GivenAMainBranchWithThreeCommitsWhen
12+
{
13+
private EmptyRepositoryFixture? fixture;
14+
15+
private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New
16+
.WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null)
17+
.WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment));
18+
19+
[OneTimeSetUp]
20+
public void OneTimeSetUp()
21+
{
22+
// C 57 minutes agov (HEAD -> main)
23+
// B 58 minutes ago
24+
// A 59 minutes ago
25+
26+
fixture = new EmptyRepositoryFixture("main");
27+
28+
fixture.MakeACommit("A");
29+
fixture.MakeACommit("B");
30+
fixture.MakeACommit("C");
31+
}
32+
33+
[OneTimeTearDown]
34+
public void OneTimeTearDown() => fixture?.Dispose();
35+
36+
[TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+1")]
37+
[TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+1")]
38+
[TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+1")]
39+
[TestCase(IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+1")]
40+
41+
[TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+1")]
42+
[TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+1")]
43+
[TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+1")]
44+
[TestCase(IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+1")]
45+
46+
[TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+1")]
47+
[TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+1")]
48+
[TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.0-foo.1+1")]
49+
[TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+1")]
50+
51+
[TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.3+1")]
52+
[TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+1")]
53+
[TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+1")]
54+
[TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+1")]
55+
public string GetVersion(IncrementStrategy increment, string? label)
56+
{
57+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
58+
.WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label))
59+
.Build();
60+
61+
return fixture!.GetVersion(trunkBased).FullSemVer;
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)