From 906647108ef947e4962b19a4be7a2eb9d565a6d4 Mon Sep 17 00:00:00 2001 From: michaelmajgaard <52096428+michaelmajgaard@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:59:03 +0200 Subject: [PATCH] fix fixture --- .../OrchestrationSettlementReportsAppFixture.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/source/settlement-report/Orchestration.SettlementReports.IntegrationTests/Fixtures/OrchestrationSettlementReportsAppFixture.cs b/source/settlement-report/Orchestration.SettlementReports.IntegrationTests/Fixtures/OrchestrationSettlementReportsAppFixture.cs index 0ce3777..b855d85 100644 --- a/source/settlement-report/Orchestration.SettlementReports.IntegrationTests/Fixtures/OrchestrationSettlementReportsAppFixture.cs +++ b/source/settlement-report/Orchestration.SettlementReports.IntegrationTests/Fixtures/OrchestrationSettlementReportsAppFixture.cs @@ -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; @@ -45,6 +47,7 @@ public OrchestrationSettlementReportsAppFixture() IntegrationTestConfiguration = new IntegrationTestConfiguration(); AzuriteManager = new AzuriteManager(useOAuth: true); + DatabaseManager = new WholesaleDatabaseManager(); DurableTaskManager = new DurableTaskManager( "AzureWebJobsStorage", @@ -66,6 +69,8 @@ public OrchestrationSettlementReportsAppFixture() [NotNull] public IDurableClient? DurableClient { get; private set; } + public WholesaleDatabaseManager DatabaseManager { get; } + private IntegrationTestConfiguration IntegrationTestConfiguration { get; } private AzuriteManager AzuriteManager { get; } @@ -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); @@ -94,7 +102,7 @@ public async Task InitializeAsync() DurableClient = DurableTaskManager.CreateClient(taskHubName: TaskHubName); } - public Task DisposeAsync() + public async Task DisposeAsync() { AppHostManager?.Dispose(); MockServer.Dispose(); @@ -103,7 +111,7 @@ public Task DisposeAsync() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) AzuriteManager.Dispose(); - return Task.CompletedTask; + await DatabaseManager.DeleteDatabaseAsync(); } public void EnsureAppHostUsesMockedDatabricksJobs() @@ -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(