Skip to content

Commit

Permalink
fix fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmajgaard committed Aug 21, 2024
1 parent abb76a1 commit 9066471
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
using Energinet.DataHub.Core.FunctionApp.TestCommon.FunctionAppHost;
using Energinet.DataHub.Core.TestCommon.Diagnostics;
using Energinet.DataHub.SettlementReport.CalculationResults.Infrastructure.Extensions.Options;
using Energinet.DataHub.SettlementReport.CalculationResults.Infrastructure.Persistence;
using Energinet.DataHub.SettlementReport.Common.Infrastructure.Extensions.Options;
using Energinet.DataHub.SettlementReport.Orchestration.SettlementReports.IntegrationTests.DurableTask;
using Energinet.DataHub.SettlementReport.Test.Core.Fixture.Database;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using WireMock.Server;
using Xunit.Abstractions;
Expand All @@ -45,6 +47,7 @@ public OrchestrationSettlementReportsAppFixture()
IntegrationTestConfiguration = new IntegrationTestConfiguration();

AzuriteManager = new AzuriteManager(useOAuth: true);
DatabaseManager = new WholesaleDatabaseManager<SettlementReportDatabaseContext>();

DurableTaskManager = new DurableTaskManager(
"AzureWebJobsStorage",
Expand All @@ -66,6 +69,8 @@ public OrchestrationSettlementReportsAppFixture()
[NotNull]
public IDurableClient? DurableClient { get; private set; }

public WholesaleDatabaseManager<SettlementReportDatabaseContext> DatabaseManager { get; }

private IntegrationTestConfiguration IntegrationTestConfiguration { get; }

private AzuriteManager AzuriteManager { get; }
Expand All @@ -80,6 +85,9 @@ public async Task InitializeAsync()
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
AzuriteManager.StartAzurite();

// Database
await DatabaseManager.CreateDatabaseAsync();

// Prepare host settings
var port = 8100;
var appHostSettings = CreateAppHostSettings(ref port);
Expand All @@ -94,7 +102,7 @@ public async Task InitializeAsync()
DurableClient = DurableTaskManager.CreateClient(taskHubName: TaskHubName);
}

public Task DisposeAsync()
public async Task DisposeAsync()
{
AppHostManager?.Dispose();
MockServer.Dispose();
Expand All @@ -103,7 +111,7 @@ public Task DisposeAsync()
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
AzuriteManager.Dispose();

return Task.CompletedTask;
await DatabaseManager.DeleteDatabaseAsync();
}

public void EnsureAppHostUsesMockedDatabricksJobs()
Expand Down Expand Up @@ -164,6 +172,11 @@ private FunctionAppHostSettings CreateAppHostSettings(ref int port)
"OrchestrationsTaskHubName",
TaskHubName);

// Database
appHostSettings.ProcessEnvironmentVariables.Add(
$"{ConnectionStringsOptions.ConnectionStrings}__{nameof(ConnectionStringsOptions.DB_CONNECTION_STRING)}",
DatabaseManager.ConnectionString);

// Databricks
// => Notice we reconfigure this setting in "EnsureAppHostUsesActualDatabricksJobs" and "EnsureAppHostUsesMockedDatabricksJobs"
appHostSettings.ProcessEnvironmentVariables.Add(
Expand Down

0 comments on commit 9066471

Please sign in to comment.