Skip to content

Commit e3fbe28

Browse files
committed
Add integration tests: Given a feature branch with one commit
1 parent c0e65e3 commit e3fbe28

8 files changed

+778
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 GivenAFeatureBranchWithOneCommitWhen
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+
// A 59 minutes ago (HEAD -> feature/foo)
23+
24+
fixture = new EmptyRepositoryFixture("feature/foo");
25+
26+
fixture.MakeACommit("A");
27+
}
28+
29+
[OneTimeTearDown]
30+
public void OneTimeTearDown() => fixture?.Dispose();
31+
32+
[TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")]
33+
[TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")]
34+
[TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")]
35+
[TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")]
36+
37+
[TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")]
38+
[TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")]
39+
[TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")]
40+
[TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")]
41+
42+
[TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")]
43+
[TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")]
44+
[TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")]
45+
[TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")]
46+
47+
[TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")]
48+
[TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")]
49+
[TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")]
50+
[TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")]
51+
public string GetVersion(IncrementStrategy increment, string? label)
52+
{
53+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
54+
.WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label))
55+
.Build();
56+
57+
return fixture!.GetVersion(trunkBased).FullSemVer;
58+
}
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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 GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMajor
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+
// A 59 minutes ago (HEAD -> feature/foo)
23+
24+
fixture = new EmptyRepositoryFixture("feature/foo");
25+
26+
fixture.MakeACommit("A +semver: major");
27+
}
28+
29+
[OneTimeTearDown]
30+
public void OneTimeTearDown() => fixture?.Dispose();
31+
32+
[TestCase(IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")]
33+
[TestCase(IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")]
34+
[TestCase(IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")]
35+
[TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")]
36+
37+
[TestCase(IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")]
38+
[TestCase(IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")]
39+
[TestCase(IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")]
40+
[TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")]
41+
42+
[TestCase(IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")]
43+
[TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")]
44+
[TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")]
45+
[TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")]
46+
47+
[TestCase(IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")]
48+
[TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")]
49+
[TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")]
50+
[TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")]
51+
public string GetVersion(IncrementStrategy increment, string? label)
52+
{
53+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
54+
.WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label))
55+
.Build();
56+
57+
return fixture!.GetVersion(trunkBased).FullSemVer;
58+
}
59+
60+
[TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")]
61+
[TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")]
62+
[TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")]
63+
[TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")]
64+
65+
[TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")]
66+
[TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")]
67+
[TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")]
68+
[TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")]
69+
70+
[TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")]
71+
[TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")]
72+
[TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")]
73+
[TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")]
74+
75+
[TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")]
76+
[TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")]
77+
[TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")]
78+
[TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")]
79+
public string GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label)
80+
{
81+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
82+
.WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)
83+
.WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled)
84+
).Build();
85+
86+
return fixture!.GetVersion(trunkBased).FullSemVer;
87+
}
88+
89+
[TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")]
90+
[TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")]
91+
[TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")]
92+
[TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")]
93+
94+
[TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")]
95+
[TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")]
96+
[TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")]
97+
[TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")]
98+
99+
[TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")]
100+
[TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")]
101+
[TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")]
102+
[TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")]
103+
104+
[TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")]
105+
[TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")]
106+
[TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")]
107+
[TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")]
108+
public string GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label)
109+
{
110+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
111+
.WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)
112+
.WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly)
113+
).Build();
114+
115+
return fixture!.GetVersion(trunkBased).FullSemVer;
116+
}
117+
}
118+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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 GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMinor
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+
// A 59 minutes ago (HEAD -> feature/foo)
23+
24+
fixture = new EmptyRepositoryFixture("feature/foo");
25+
26+
fixture.MakeACommit("A +semver: minor");
27+
}
28+
29+
[OneTimeTearDown]
30+
public void OneTimeTearDown() => fixture?.Dispose();
31+
32+
[TestCase(IncrementStrategy.None, null, ExpectedResult = "0.1.0-1+1")]
33+
[TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-1+1")]
34+
[TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")]
35+
[TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")]
36+
37+
[TestCase(IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")]
38+
[TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")]
39+
[TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")]
40+
[TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")]
41+
42+
[TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")]
43+
[TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")]
44+
[TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")]
45+
[TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")]
46+
47+
[TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")]
48+
[TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")]
49+
[TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")]
50+
[TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")]
51+
public string GetVersion(IncrementStrategy increment, string? label)
52+
{
53+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
54+
.WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label))
55+
.Build();
56+
57+
return fixture!.GetVersion(trunkBased).FullSemVer;
58+
}
59+
60+
[TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")]
61+
[TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")]
62+
[TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")]
63+
[TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")]
64+
65+
[TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")]
66+
[TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")]
67+
[TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")]
68+
[TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")]
69+
70+
[TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")]
71+
[TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")]
72+
[TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")]
73+
[TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")]
74+
75+
[TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")]
76+
[TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")]
77+
[TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")]
78+
[TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")]
79+
public string GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label)
80+
{
81+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
82+
.WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)
83+
.WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled)
84+
).Build();
85+
86+
return fixture!.GetVersion(trunkBased).FullSemVer;
87+
}
88+
89+
[TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")]
90+
[TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")]
91+
[TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")]
92+
[TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")]
93+
94+
[TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")]
95+
[TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")]
96+
[TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")]
97+
[TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")]
98+
99+
[TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")]
100+
[TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")]
101+
[TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")]
102+
[TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")]
103+
104+
[TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")]
105+
[TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")]
106+
[TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")]
107+
[TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")]
108+
public string GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label)
109+
{
110+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
111+
.WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)
112+
.WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly)
113+
).Build();
114+
115+
return fixture!.GetVersion(trunkBased).FullSemVer;
116+
}
117+
}
118+
}

0 commit comments

Comments
 (0)