Skip to content

Commit 1f7f686

Browse files
committed
Add integration tests: Given a feature branch with two commits when first commit tagged as pr-release, bar, foo
1 parent edcdba7 commit 1f7f686

3 files changed

+189
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreRelease
12+
{
13+
private EmptyRepositoryFixture? fixture;
14+
15+
private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New
16+
.WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null)
17+
.WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false));
18+
19+
[OneTimeSetUp]
20+
public void OneTimeSetUp()
21+
{
22+
// B 58 minutes ago (HEAD -> feature/foo)
23+
// A 59 minutes ago (tag 0.0.3-4)
24+
25+
fixture = new EmptyRepositoryFixture("feature/foo");
26+
27+
fixture.MakeACommit("A");
28+
fixture.ApplyTag("0.0.3-4");
29+
fixture.MakeACommit("B");
30+
}
31+
32+
[OneTimeTearDown]
33+
public void OneTimeTearDown() => fixture?.Dispose();
34+
35+
[TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.3-5+1")]
36+
[TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-5+1")]
37+
[TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.3-5+1")]
38+
[TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.3-5+1")]
39+
40+
[TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.3-5+1")]
41+
[TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-5+1")]
42+
[TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.0.3-5+1")]
43+
[TestCase(IncrementStrategy.Major, "", ExpectedResult = "0.0.3-5+1")]
44+
45+
[TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+2")]
46+
[TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+2")]
47+
[TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")]
48+
[TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")]
49+
50+
[TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+2")]
51+
[TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+2")]
52+
[TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")]
53+
[TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")]
54+
public string GetVersion(IncrementStrategy increment, string? label)
55+
{
56+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
57+
.WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label))
58+
.Build();
59+
60+
return fixture!.GetVersion(trunkBased).FullSemVer;
61+
}
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseBar
12+
{
13+
private EmptyRepositoryFixture? fixture;
14+
15+
private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New
16+
.WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null)
17+
.WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false));
18+
19+
[OneTimeSetUp]
20+
public void OneTimeSetUp()
21+
{
22+
// B 58 minutes ago (HEAD -> feature/foo)
23+
// A 59 minutes ago (tag 0.0.3-bar)
24+
25+
fixture = new EmptyRepositoryFixture("feature/foo");
26+
27+
fixture.MakeACommit("A");
28+
fixture.ApplyTag("0.0.3-bar");
29+
fixture.MakeACommit("B");
30+
}
31+
32+
[OneTimeTearDown]
33+
public void OneTimeTearDown() => fixture?.Dispose();
34+
35+
[TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.3-bar+1")]
36+
[TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-bar+1")]
37+
[TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.3-bar+1")]
38+
[TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.3-bar+1")]
39+
40+
[TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+2")]
41+
[TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+2")]
42+
[TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")]
43+
[TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")]
44+
45+
[TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+2")]
46+
[TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+2")]
47+
[TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")]
48+
[TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")]
49+
50+
[TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar+1")]
51+
[TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar+1")]
52+
[TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.3-bar+1")]
53+
[TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "0.0.3-bar+1")]
54+
public string GetVersion(IncrementStrategy increment, string? label)
55+
{
56+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
57+
.WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label))
58+
.Build();
59+
60+
return fixture!.GetVersion(trunkBased).FullSemVer;
61+
}
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseFoo
12+
{
13+
private EmptyRepositoryFixture? fixture;
14+
15+
private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New
16+
.WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null)
17+
.WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false));
18+
19+
[OneTimeSetUp]
20+
public void OneTimeSetUp()
21+
{
22+
// B 58 minutes ago (HEAD -> feature/foo)
23+
// A 59 minutes ago (tag 0.0.3-foo.4)
24+
25+
fixture = new EmptyRepositoryFixture("feature/foo");
26+
27+
fixture.MakeACommit("A");
28+
fixture.ApplyTag("0.0.3-foo.4");
29+
fixture.MakeACommit("B");
30+
}
31+
32+
[OneTimeTearDown]
33+
public void OneTimeTearDown() => fixture?.Dispose();
34+
35+
[TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.3-foo.5+1")]
36+
[TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.5+1")]
37+
[TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.3-foo.5+1")]
38+
[TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.3-foo.5+1")]
39+
40+
[TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+2")]
41+
[TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+2")]
42+
[TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")]
43+
[TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")]
44+
45+
[TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.5+1")]
46+
[TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.5+1")]
47+
[TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.3-foo.5+1")]
48+
[TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "0.0.3-foo.5+1")]
49+
50+
[TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+2")]
51+
[TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+2")]
52+
[TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")]
53+
[TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")]
54+
public string GetVersion(IncrementStrategy increment, string? label)
55+
{
56+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
57+
.WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label))
58+
.Build();
59+
60+
return fixture!.GetVersion(trunkBased).FullSemVer;
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)