Skip to content

Commit 7db7e8f

Browse files
committed
Added test for config outdated error
1 parent f0374b5 commit 7db7e8f

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/GitVersionCore.Tests/ConfigProviderTests.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,23 @@ public void RegexIsRequired()
100100
tag: bugfix";
101101
SetupConfigFileContent(text);
102102
var ex = Should.Throw<GitVersionConfigurationException>(() => ConfigurationProvider.Provide(repoPath, fileSystem));
103-
ex.Message.ShouldBe("Branch configuration 'bug' is missing required configuration 'regex'");
103+
ex.Message.ShouldBe("Branch configuration 'bug' is missing required configuration 'regex'\n\n" +
104+
"See http://gitversion.readthedocs.io/en/latest/configuration/ for more info");
105+
}
106+
107+
[Test]
108+
public void SourceBranchIsRequired()
109+
{
110+
const string text = @"
111+
next-version: 2.0.0
112+
branches:
113+
bug:
114+
regex: 'bug[/-]'
115+
tag: bugfix";
116+
SetupConfigFileContent(text);
117+
var ex = Should.Throw<GitVersionConfigurationException>(() => ConfigurationProvider.Provide(repoPath, fileSystem));
118+
ex.Message.ShouldBe("Branch configuration 'bug' is missing required configuration 'source-branches'\n\n" +
119+
"See http://gitversion.readthedocs.io/en/latest/configuration/ for more info");
104120
}
105121

106122
[Test]

src/GitVersionCore/Configuration/ConfigurationProvider.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,15 @@ public static void ApplyDefaultsTo(Config config)
161161
var regex = branchConfig.Value.Regex;
162162
if (regex == null)
163163
{
164-
throw new GitVersionConfigurationException($"Branch configuration '{branchConfig.Key}' is missing required configuration 'regex'");
164+
throw new GitVersionConfigurationException($"Branch configuration '{branchConfig.Key}' is missing required configuration 'regex'\n\n" +
165+
"See http://gitversion.readthedocs.io/en/latest/configuration/ for more info");
165166
}
166167

167168
var sourceBranches = branchConfig.Value.SourceBranches;
168169
if (sourceBranches == null)
169170
{
170-
throw new GitVersionConfigurationException($"Branch configuration '{branchConfig.Key}' is missing required configuration 'source-branches'");
171+
throw new GitVersionConfigurationException($"Branch configuration '{branchConfig.Key}' is missing required configuration 'source-branches'\n\n" +
172+
"See http://gitversion.readthedocs.io/en/latest/configuration/ for more info");
171173
}
172174

173175
ApplyBranchDefaults(config, branchConfig.Value, regex, sourceBranches);

0 commit comments

Comments
 (0)