Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/GitVersionCore.Tests/NamedConfigFileLocatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ public void NoWarnOnCustomYmlFileOutsideRepoPath()
stringLogger.Length.ShouldBe(0);
}

[Test]
public void ThrowsExceptionOnCustomYmlFileDoesNotExist()
{
var sp = GetServiceProvider(arguments);
configFileLocator = sp.GetService<IConfigFileLocator>();

var exception = Should.Throw<WarningException>(() => { configFileLocator.Verify(workingPath, repoPath); });

var workingPathFileConfig = Path.Combine(workingPath, arguments.ConfigFile);
var repoPathFileConfig = Path.Combine(repoPath, arguments.ConfigFile);
var expectedMessage = $"The configuration file was not found at '{workingPathFileConfig}' or '{repoPathFileConfig}'";
exception.Message.ShouldBe(expectedMessage);
}

private string SetupConfigFileContent(string text, string fileName = null, string path = null)
{
if (string.IsNullOrEmpty(fileName)) fileName = ((NamedConfigFileLocator)configFileLocator).FilePath;
Expand Down
5 changes: 5 additions & 0 deletions src/GitVersionCore/Configuration/NamedConfigFileLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ private void WarnAboutAmbiguousConfigFileSelection(string workingDirectory, stri
{
throw new WarningException($"Ambiguous config file selection from '{workingConfigFile}' and '{projectRootConfigFile}'");
}

if (!hasConfigInProjectRootDirectory && !hasConfigInWorkingDirectory)
{
throw new WarningException($"The configuration file was not found at '{workingConfigFile}' or '{projectRootConfigFile}'");
}
}
}
}