Skip to content

Commit 0374427

Browse files
authored
Fix integration tests (#10655)
1 parent bc21cd6 commit 0374427

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

test/WebJobs.Script.Tests.Integration/Management/InstanceManagerTests.cs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Net.Http;
1010
using System.Threading;
1111
using System.Threading.Tasks;
12+
using Castle.Core.Logging;
1213
using Microsoft.Azure.WebJobs.Script.Diagnostics;
1314
using Microsoft.Azure.WebJobs.Script.WebHost;
1415
using Microsoft.Azure.WebJobs.Script.WebHost.Management;
@@ -355,7 +356,7 @@ public async Task ValidateContext_InvalidZipUrl_WebsiteUseZip_ReturnsError()
355356
{
356357
var environmentSettings = new Dictionary<string, string>()
357358
{
358-
{ EnvironmentSettingNames.AzureWebsiteZipDeployment, "http://invalid.com/invalid/dne" }
359+
{ EnvironmentSettingNames.AzureWebsiteZipDeployment, "http://invalid.test/invalid/dne" }
359360
};
360361

361362
var environment = new TestEnvironment();
@@ -438,7 +439,7 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_Only()
438439
{
439440
var environment = new Dictionary<string, string>()
440441
{
441-
{ EnvironmentSettingNames.AzureWebsiteZipDeployment, "http://microsoft.com" }
442+
{ EnvironmentSettingNames.AzureWebsiteZipDeployment, "https://valid-zip.test" }
442443
};
443444
var assignmentContext = new HostAssignmentContext
444445
{
@@ -448,7 +449,19 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_Only()
448449
IsWarmupRequest = false
449450
};
450451

451-
string error = await _instanceManager.ValidateContext(assignmentContext);
452+
var handlerMock = new Mock<HttpMessageHandler>();
453+
handlerMock.Protected().Setup<Task<HttpResponseMessage>>("SendAsync",
454+
ItExpr.IsAny<HttpRequestMessage>(),
455+
ItExpr.IsAny<CancellationToken>()).ReturnsAsync(new HttpResponseMessage
456+
{
457+
StatusCode = HttpStatusCode.OK,
458+
});
459+
460+
var instanceManager = new AtlasInstanceManager(_optionsFactory, TestHelpers.CreateHttpClientFactory(handlerMock.Object),
461+
_scriptWebEnvironment, _environment, _loggerFactory.CreateLogger<AtlasInstanceManager>(),
462+
new TestMetricsLogger(), null, _runFromPackageHandler, _packageDownloadHandler.Object);
463+
464+
string error = await instanceManager.ValidateContext(assignmentContext);
452465
Assert.Null(error);
453466

454467
string[] expectedOutputLines =
@@ -538,8 +551,8 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_With_ScmPackageDefi
538551
{
539552
var environment = new Dictionary<string, string>()
540553
{
541-
{ EnvironmentSettingNames.AzureWebsiteZipDeployment, "http://microsoft.com" },
542-
{ EnvironmentSettingNames.ScmRunFromPackage, "http://microsoft.com" }
554+
{ EnvironmentSettingNames.AzureWebsiteZipDeployment, "https://valid.test" },
555+
{ EnvironmentSettingNames.ScmRunFromPackage, "https://valid.test" }
543556
};
544557
var assignmentContext = new HostAssignmentContext
545558
{
@@ -549,7 +562,19 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_With_ScmPackageDefi
549562
IsWarmupRequest = false
550563
};
551564

552-
string error = await _instanceManager.ValidateContext(assignmentContext);
565+
var handlerMock = new Mock<HttpMessageHandler>();
566+
handlerMock.Protected().Setup<Task<HttpResponseMessage>>("SendAsync",
567+
ItExpr.IsAny<HttpRequestMessage>(),
568+
ItExpr.IsAny<CancellationToken>()).ReturnsAsync(new HttpResponseMessage
569+
{
570+
StatusCode = HttpStatusCode.OK,
571+
});
572+
573+
var instanceManager = new AtlasInstanceManager(_optionsFactory, TestHelpers.CreateHttpClientFactory(handlerMock.Object),
574+
_scriptWebEnvironment, _environment, _loggerFactory.CreateLogger<AtlasInstanceManager>(),
575+
new TestMetricsLogger(), null, _runFromPackageHandler, _packageDownloadHandler.Object);
576+
577+
string error = await instanceManager.ValidateContext(assignmentContext);
553578
Assert.Null(error);
554579

555580
string[] expectedOutputLines =

test/WebJobs.Script.Tests.Shared/TestConfigurationBuilderExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using System.IO;
6-
using System.Linq;
76
using Microsoft.Extensions.Configuration;
87

98
namespace Microsoft.Azure.WebJobs.Script.Tests

0 commit comments

Comments
 (0)