Skip to content

Commit

Permalink
Ensure database deleted before running integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
simpat-adam committed Dec 4, 2023
1 parent db84ac3 commit 44f15a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 3 additions & 0 deletions DataImport.Models.Tests/SetUpFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ public void GlobalSetUp()
// Migrations MUST run first, before any logging attempts,
// so that database logging can be properly initialized.
using (var context = new SqlDataImportDbContext(dbContextLogger, optionsBuilder.Options))
{
context.Database.EnsureDeleted();
context.Database.Migrate();
}

logger.LogInformation("{assembly} Starting", Assembly.GetExecutingAssembly().GetName().Name);
}
Expand Down
10 changes: 3 additions & 7 deletions DataImport.Web.Tests/SetUpFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

using System;
using DataImport.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using System;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Serilog;
using static DataImport.Web.Tests.Testing;

Expand All @@ -32,18 +33,13 @@ public async Task GlobalSetUp()

using (var context = Testing.Services.GetRequiredService<SqlDataImportDbContext>())
{
if (RunningUnderTeamCity())
context.Database.EnsureDeleted();

context.Database.EnsureDeleted();
context.Database.Migrate();
}

Log.Information(Assembly.GetExecutingAssembly().GetName().Name + " Starting");

await ConfigureForOdsApiV311();
}

private static bool RunningUnderTeamCity()
=> Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") != null;
}
}

0 comments on commit 44f15a6

Please sign in to comment.