Skip to content

Commit 9245f0e

Browse files
Merge pull request #62 from browserstack/chore/green-unit-tests
test: fix pre-existing unit-test failures (green the suite)
2 parents 2fda4e2 + 9a38c70 commit 9245f0e

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

‎BrowserStackLocal/BrowserStackLocal Unit Tests/BrowserStackTunnelTests.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ private static bool IsExecutable(string path)
192192
public class TunnelClass : BrowserStackTunnel
193193
{
194194
public TunnelClass() : base("test-user-agent") {}
195+
// Stub the network boundary so these binary-path/fallback unit tests exercise
196+
// the real path-resolution logic without making a live HTTP call to the
197+
// endpoint API (which addBinaryPath triggers on first invocation).
198+
protected override string fetchSourceUrl(string accessKey)
199+
{
200+
return null;
201+
}
195202
public StringBuilder getOutputBuilder()
196203
{
197204
return output;

‎BrowserStackLocal/BrowserStackLocal Unit Tests/LocalTests.cs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void TestWorksForBinaryPath()
110110
tunnelMock.Setup(mock => mock.Run("dummyKey", "", logAbsolute, "start"));
111111
local.setTunnel(tunnelMock.Object);
112112
local.start(options);
113-
tunnelMock.Verify(mock => mock.addBinaryPath("dummyPath", "", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
113+
tunnelMock.Verify(mock => mock.addBinaryPath("dummyPath", "dummyKey", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
114114
tunnelMock.Verify(mock => mock.addBinaryArguments(It.Is<List<string>>(a =>
115115
InOrder(a, "-logFile", logAbsolute))), Times.Once());
116116
tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Once());
@@ -133,7 +133,7 @@ public void TestWorksWithBooleanOptions()
133133
tunnelMock.Setup(mock => mock.Run("dummyKey", "", logAbsolute, "start"));
134134
local.setTunnel(tunnelMock.Object);
135135
local.start(options);
136-
tunnelMock.Verify(mock => mock.addBinaryPath("", "", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
136+
tunnelMock.Verify(mock => mock.addBinaryPath("", "dummyKey", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
137137
tunnelMock.Verify(mock => mock.addBinaryArguments(It.Is<List<string>>(a =>
138138
InOrder(a, "-vvv", "-force", "-forcelocal", "-forceproxy", "-onlyAutomate"))), Times.Once());
139139
tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Once());
@@ -157,7 +157,7 @@ public void TestWorksWithValueOptions()
157157
tunnelMock.Setup(mock =>mock.Run("dummyKey", "", logAbsolute, "start"));
158158
local.setTunnel(tunnelMock.Object);
159159
local.start(options);
160-
tunnelMock.Verify(mock => mock.addBinaryPath("", "", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
160+
tunnelMock.Verify(mock => mock.addBinaryPath("", "dummyKey", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
161161
tunnelMock.Verify(mock => mock.addBinaryArguments(It.Is<List<string>>(a =>
162162
InOrder(a, "-localIdentifier", "dummyIdentifier", "dummyHost", "-proxyHost", "dummyHost",
163163
"-proxyPort", "dummyPort", "-proxyUser", "dummyUser", "-proxyPass", "dummyPass"))
@@ -181,7 +181,7 @@ public void TestWorksWithCustomOptions()
181181
tunnelMock.Setup(mock => mock.Run("dummyKey", "", logAbsolute, "start"));
182182
local.setTunnel(tunnelMock.Object);
183183
local.start(options);
184-
tunnelMock.Verify(mock => mock.addBinaryPath("", "", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
184+
tunnelMock.Verify(mock => mock.addBinaryPath("", "dummyKey", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
185185
tunnelMock.Verify(mock => mock.addBinaryArguments(It.Is<List<string>>(a =>
186186
InOrder(a, "-customBoolKey1", "-customBoolKey2", "-customKey1", "customValue1",
187187
"-customKey2", "customValue2"))
@@ -207,7 +207,7 @@ public void TestCallsFallbackOnFailure()
207207
});
208208
local.setTunnel(tunnelMock.Object);
209209
local.start(options);
210-
tunnelMock.Verify(mock => mock.addBinaryPath("", "", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
210+
tunnelMock.Verify(mock => mock.addBinaryPath("", "dummyKey", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
211211
tunnelMock.Verify(mock => mock.addBinaryArguments(It.Is<List<string>>(a =>
212212
InOrder(a, "-logFile", logAbsolute))), Times.Once());
213213
tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Exactly(2));
@@ -227,7 +227,7 @@ public void TestKillsTunnel()
227227
local.setTunnel(tunnelMock.Object);
228228
local.start(options);
229229
local.stop();
230-
tunnelMock.Verify(mock => mock.addBinaryPath("", "", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
230+
tunnelMock.Verify(mock => mock.addBinaryPath("", "dummyKey", It.IsAny<bool>(), It.IsAny<Exception>()), Times.Once);
231231
tunnelMock.Verify(mock => mock.addBinaryArguments(It.Is<List<string>>(a =>
232232
InOrder(a, "-logFile", logAbsolute))), Times.Once());
233233
tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Once());

‎BrowserStackLocal/BrowserStackLocal/BrowserStackTunnel.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public void modifyBinaryPermission()
190190
}
191191
}
192192

193-
private string fetchSourceUrl(string accessKey)
193+
protected virtual string fetchSourceUrl(string accessKey)
194194
{
195195
var url = "https://local.browserstack.com/binary/api/v1/endpoint";
196196

0 commit comments

Comments
 (0)