Skip to content

Commit 1b41013

Browse files
committed
Add a test for well-known source-branches
These two tests work together to prove success and failure scenarios work as expected.
1 parent 43ad3cf commit 1b41013

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/GitVersionCore.Tests/Configuration/ConfigProviderTests.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public void SourceBranchIsRequired()
117117
"See https://gitversion.net/docs/configuration/ for more info");
118118
}
119119

120-
[Test]
121-
public void SourceBranchesShouldExist()
120+
[Test(Description = "This test proves the configuration validation will fail early with a helpful message when a branch listed in source-branches has no configuration.")]
121+
public void SourceBranchesValidationShouldFailWhenMatchingBranchConfigurationIsMissing()
122122
{
123123
const string text = @"
124124
branches:
@@ -132,6 +132,23 @@ public void SourceBranchesShouldExist()
132132
"See https://gitversion.net/docs/configuration/ for more info");
133133
}
134134

135+
[Test(Description = "Well-known branches may not be present in the configuration file. This test confirms the validation check succeeds when the source-branches configuration contain these well-known branches.")]
136+
[TestCase(Config.MasterBranchKey)]
137+
[TestCase(Config.DevelopBranchKey)]
138+
public void SourceBranchesValidationShouldSucceedForWellKnownBranches(string wellKnownBranchKey)
139+
{
140+
var text = $@"
141+
branches:
142+
bug:
143+
regex: 'bug[/-]'
144+
tag: bugfix
145+
source-branches: [{wellKnownBranchKey}]";
146+
SetupConfigFileContent(text);
147+
var config = configProvider.Provide(repoPath);
148+
149+
config.Branches["bug"].SourceBranches.ShouldBe(new List<string> { wellKnownBranchKey });
150+
}
151+
135152
[Test]
136153
public void CanProvideConfigForNewBranch()
137154
{

0 commit comments

Comments
 (0)