Skip to content

Commit 0054036

Browse files
committed
Don't try to reset the path by passing in empty strings
The only documented way of resetting a search path is by passing null, all these other variants may have worked at some point, but that was pure coincidence.
1 parent efb0b10 commit 0054036

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

LibGit2Sharp.Tests/ConfigurationFixture.cs

+6-21
Original file line numberDiff line numberDiff line change
@@ -455,15 +455,6 @@ public void CanSetAndGetMultipleSearchPaths()
455455
[Fact]
456456
public void CanResetSearchPaths()
457457
{
458-
// all of these calls should reset the config path to the default
459-
Action[] resetActions =
460-
{
461-
() => GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global),
462-
() => GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global, null),
463-
() => GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global, string.Empty),
464-
() => GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global, new string[] { }),
465-
};
466-
467458
// record the default search path
468459
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global, null);
469460
var oldPaths = GlobalSettings.GetConfigSearchPaths(ConfigurationLevel.Global);
@@ -472,19 +463,13 @@ public void CanResetSearchPaths()
472463
// generate a non-default path to set
473464
var newPaths = new string[] { Path.Combine(Constants.TemporaryReposPath, Path.GetRandomFileName()) };
474465

475-
foreach (var tryToReset in resetActions)
476-
{
477-
// change to the non-default path
478-
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global, newPaths);
479-
Assert.Equal(newPaths, GlobalSettings.GetConfigSearchPaths(ConfigurationLevel.Global));
480-
481-
// set it back to the default
482-
tryToReset();
483-
Assert.Equal(oldPaths, GlobalSettings.GetConfigSearchPaths(ConfigurationLevel.Global));
484-
}
466+
// change to the non-default path
467+
GlobalSettings.SetConfigSearchPaths (ConfigurationLevel.Global, newPaths);
468+
Assert.Equal (newPaths, GlobalSettings.GetConfigSearchPaths (ConfigurationLevel.Global));
485469

486-
// make sure the config paths are reset after the test ends
487-
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global, null);
470+
// set it back to the default
471+
GlobalSettings.SetConfigSearchPaths (ConfigurationLevel.Global, null);
472+
Assert.Equal (oldPaths, GlobalSettings.GetConfigSearchPaths (ConfigurationLevel.Global));
488473
}
489474

490475
[Fact]

0 commit comments

Comments
 (0)