Skip to content

Commit 4297925

Browse files
committed
updating tests to latest releases
1 parent 9df6003 commit 4297925

File tree

6 files changed

+31
-21
lines changed

6 files changed

+31
-21
lines changed

test/WebJobs.Script.Tests.Integration/CosmosDB/CosmosDBEndToEndTestsBase.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
using Microsoft.Azure.Documents;
88
using Microsoft.Azure.Documents.Client;
99
using Microsoft.Azure.WebJobs.Script.Models;
10-
using Microsoft.Azure.WebJobs.Script.Rpc;
10+
using Microsoft.Extensions.Configuration;
1111
using Microsoft.Extensions.DependencyInjection;
12-
using Microsoft.Extensions.Hosting;
1312
using Microsoft.WindowsAzure.Storage.Queue;
1413
using Xunit;
1514

@@ -24,8 +23,8 @@ public CosmosDBEndToEndTestsBase(TTestFixture fixture) : base(fixture)
2423

2524
protected async Task CosmosDBTriggerToBlobTest()
2625
{
27-
// CosmosDB tests need the following environment vars:
28-
// "AzureWebJobsCosmosDBConnectionString" -- the connection string to the account
26+
// CosmosDB tests need the following connection string:
27+
// "ConnectionStrings:CosmosDB" -- the connection string to the account
2928

3029
// Waiting for the Processor to acquire leases
3130
await Task.Delay(10000);
@@ -59,8 +58,8 @@ protected async Task CosmosDBTriggerToBlobTest()
5958

6059
protected async Task CosmosDBTest()
6160
{
62-
// DocumentDB tests need the following environment vars:
63-
// "AzureWebJobsCosmosDBConnectionString" -- the connection string to the account
61+
// DocumentDB tests need the following connection string:
62+
// "ConnectionStrings:CosmosDB" -- the connection string to the account
6463
string id = Guid.NewGuid().ToString();
6564

6665
await Fixture.Host.BeginFunctionAsync("CosmosDBOut", id);
@@ -98,7 +97,7 @@ protected override ExtensionPackageReference[] GetExtensionsToInstall()
9897
new ExtensionPackageReference
9998
{
10099
Id = "Microsoft.Azure.WebJobs.Extensions.CosmosDB",
101-
Version = "3.0.0-beta9*"
100+
Version = "3.0.1"
102101
}
103102
};
104103
}
@@ -120,8 +119,11 @@ public async Task InitializeDocumentClient()
120119
{
121120
if (DocumentClient == null)
122121
{
123-
var builder = new System.Data.Common.DbConnectionStringBuilder();
124-
builder.ConnectionString = Environment.GetEnvironmentVariable("AzureWebJobsCosmosDBConnectionString");
122+
var builder = new System.Data.Common.DbConnectionStringBuilder
123+
{
124+
ConnectionString = TestHelpers.GetTestConfiguration().GetConnectionString("CosmosDB")
125+
};
126+
125127
var serviceUri = new Uri(builder["AccountEndpoint"].ToString());
126128

127129
DocumentClient = new DocumentClient(serviceUri, builder["AccountKey"].ToString());

test/WebJobs.Script.Tests.Integration/EventHubs/EventHubsEndToEndTestsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected override ExtensionPackageReference[] GetExtensionsToInstall()
6767
new ExtensionPackageReference
6868
{
6969
Id = "Microsoft.Azure.WebJobs.Extensions.EventHubs",
70-
Version = "3.0.0-11458"
70+
Version = "3.0.0"
7171
}
7272
};
7373
}

test/WebJobs.Script.Tests.Integration/TestFunctionHost.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ public TestFunctionHost(string scriptPath, string logPath,
6464
services.Replace(new ServiceDescriptor(typeof(IOptions<ScriptApplicationHostOptions>), new OptionsWrapper<ScriptApplicationHostOptions>(_hostOptions)));
6565
services.Replace(new ServiceDescriptor(typeof(IOptionsMonitor<ScriptApplicationHostOptions>), optionsMonitor));
6666

67-
services.AddSingleton<IConfigureBuilder<IConfigurationBuilder>>(_ => new DelegatedConfigureBuilder<IConfigurationBuilder>(configureAppConfiguration));
67+
services.AddSingleton<IConfigureBuilder<IConfigurationBuilder>>(_ => new DelegatedConfigureBuilder<IConfigurationBuilder>(c =>
68+
{
69+
c.AddTestSettings();
70+
configureAppConfiguration?.Invoke(c);
71+
}));
6872

6973
configureServices?.Invoke(services);
7074
})

test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/EndToEndTestFixture.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
5+
using System.Collections.Generic;
56
using System.IO;
67
using System.Linq;
78
using System.Threading.Tasks;
@@ -61,8 +62,6 @@ protected virtual ExtensionPackageReference[] GetExtensionsToInstall()
6162

6263
public async Task InitializeAsync()
6364
{
64-
Environment.SetEnvironmentVariable(LanguageWorkerConstants.FunctionWorkerRuntimeSettingName, _functionsWorkerRuntime);
65-
6665
_copiedRootPath = Path.Combine(Path.GetTempPath(), "FunctionsE2E", DateTime.UtcNow.ToString("yyMMdd-HHmmss"));
6766
FileUtility.CopyDirectory(_rootPath, _copiedRootPath);
6867

@@ -80,7 +79,13 @@ public async Task InitializeAsync()
8079
}
8180

8281
string logPath = Path.Combine(Path.GetTempPath(), @"Functions");
83-
Host = new TestFunctionHost(_copiedRootPath, logPath, ConfigureJobHost);
82+
Host = new TestFunctionHost(_copiedRootPath, logPath, ConfigureJobHost, configureAppConfiguration: s =>
83+
{
84+
s.AddInMemoryCollection(new Dictionary<string, string>()
85+
{
86+
{ LanguageWorkerConstants.FunctionWorkerRuntimeSettingName, _functionsWorkerRuntime }
87+
});
88+
});
8489

8590
string connectionString = Host.JobHostServices.GetService<IConfiguration>().GetWebJobsConnectionString(ConnectionStringNames.Storage);
8691
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/EndToEndTestsBase.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ public abstract class EndToEndTestsBase<TTestFixture> :
2828
IClassFixture<TTestFixture> where TTestFixture : EndToEndTestFixture, new()
2929
{
3030
private INameResolver _nameResolver;
31+
private IConfiguration _configuration;
3132
private static readonly ScriptSettingsManager SettingsManager = ScriptSettingsManager.Instance;
3233

3334
public EndToEndTestsBase(TTestFixture fixture)
3435
{
35-
var config = new ConfigurationBuilder()
36-
.AddEnvironmentVariables()
37-
.Build();
36+
_configuration = TestHelpers.GetTestConfiguration();
3837

39-
_nameResolver = new DefaultNameResolver(config);
38+
_nameResolver = new DefaultNameResolver(_configuration);
4039
Fixture = fixture;
4140
}
4241

@@ -342,8 +341,8 @@ protected async Task<Document> WaitForDocumentAsync(string itemId, string textTo
342341
{
343342
var docUri = UriFactory.CreateDocumentUri("ItemDb", "ItemCollection", itemId);
344343

345-
// We know the tests are using the default INameResolver and the default setting.
346-
var connectionString = _nameResolver.Resolve("AzureWebJobsCosmosDBConnectionString");
344+
// We know the tests are using the default connection string.
345+
var connectionString = _configuration.GetConnectionString("CosmosDB");
347346
var builder = new DbConnectionStringBuilder
348347
{
349348
ConnectionString = connectionString

test/WebJobs.Script.Tests.Integration/WebJobs.Script.Tests.Integration.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<NoWarn>NU1701</NoWarn>
2828
</PackageReference>
2929
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" />
30-
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="1.9.1" />
30+
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.0.0" />
3131
<PackageReference Include="Microsoft.Azure.EventHubs" Version="2.1.0" />
3232
<PackageReference Include="Microsoft.Azure.Functions.NodeJsWorker" Version="1.0.0-beta4-10082" />
3333
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0" />

0 commit comments

Comments
 (0)