Skip to content

Commit f39343b

Browse files
committed
macos environment: unit test for ignoring paths
Add a unit test to verify ignoring paths when searching the PATH for executables works as expected.
1 parent 57a566a commit f39343b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/shared/Core.Tests/EnvironmentTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using GitCredentialManager.Interop.Posix;
45
using GitCredentialManager.Interop.Windows;
56
using GitCredentialManager.Tests.Objects;
@@ -123,5 +124,31 @@ public void PosixEnvironment_TryLocateExecutable_ExistsMultiple_ReturnTrueAndFir
123124
Assert.True(actualResult);
124125
Assert.Equal(expectedPath, actualPath);
125126
}
127+
128+
[PlatformFact(Platforms.MacOS)]
129+
public void MacOSEnvironment_TryLocateExecutable_Paths_Are_Ignored()
130+
{
131+
List<string> pathsToIgnore = new List<string>()
132+
{
133+
"/home/john.doe/bin/foo"
134+
};
135+
string expectedPath = "/usr/local/bin/foo";
136+
137+
var fs = new TestFileSystem
138+
{
139+
Files = new Dictionary<string, byte[]>
140+
{
141+
[pathsToIgnore.FirstOrDefault()] = Array.Empty<byte>(),
142+
[expectedPath] = Array.Empty<byte>(),
143+
}
144+
};
145+
var envars = new Dictionary<string, string> {["PATH"] = PosixPathVar};
146+
var env = new PosixEnvironment(fs, envars);
147+
148+
bool actualResult = env.TryLocateExecutable(PosixExecName, pathsToIgnore, out string actualPath);
149+
150+
Assert.True(actualResult);
151+
Assert.Equal(expectedPath, actualPath);
152+
}
126153
}
127154
}

0 commit comments

Comments
 (0)