|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
| 3 | +using System.Linq; |
3 | 4 | using GitCredentialManager.Interop.Posix;
|
4 | 5 | using GitCredentialManager.Interop.Windows;
|
5 | 6 | using GitCredentialManager.Tests.Objects;
|
@@ -123,5 +124,31 @@ public void PosixEnvironment_TryLocateExecutable_ExistsMultiple_ReturnTrueAndFir
|
123 | 124 | Assert.True(actualResult);
|
124 | 125 | Assert.Equal(expectedPath, actualPath);
|
125 | 126 | }
|
| 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 | + } |
126 | 153 | }
|
127 | 154 | }
|
0 commit comments