Skip to content

Commit 363ef8d

Browse files
author
Furkan Küçük
committed
ConfigFileLocator.GetConfigurationFile tests improved
1 parent e323c92 commit 363ef8d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/GitVersion.Configuration.Tests/Configuration/ConfigurationFileLocatorTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,25 @@ public void ReturnConfigurationFilePathIfCustomConfigurationIsSet()
185185
config.ShouldNotBe(Path.GetFullPath("Configuration/CustomConfig.yaml"));
186186
}
187187

188+
[TestCase(null)]
189+
[TestCase("")]
190+
[TestCase(" ")]
191+
[TestCase("Configuration/CustomConfig2.yaml")]
192+
public void ReturnConfigurationFilePathIfCustomConfigurationIsSet_InvalidConfigurationFilePaths(string? configFile)
193+
{
194+
this.workingPath = this.repoPath;
195+
196+
this.gitVersionOptions = new() { ConfigurationInfo = { ConfigurationFile = configFile } };
197+
var sp = GetServiceProvider(this.gitVersionOptions);
198+
this.configFileLocator = sp.GetRequiredService<IConfigurationFileLocator>();
199+
this.fileSystem = sp.GetRequiredService<IFileSystem>();
200+
201+
using var _ = this.fileSystem.SetupConfigFile(path: this.workingPath, fileName: ConfigFile);
202+
203+
var config = this.configFileLocator.GetConfigurationFile(this.workingPath);
204+
config.ShouldNotBe(null);
205+
}
206+
188207
[Test]
189208
public void DoNotThrowWhenConfigFileIsInSubDirectoryOfRepoPath()
190209
{

0 commit comments

Comments
 (0)