Add test to check that there are no pending database model changes (#25762)
This commit is contained in:
@@ -11,7 +11,6 @@ using Robust.Shared.Enums;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.UnitTesting;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Preferences
|
||||
@@ -119,6 +118,17 @@ namespace Content.IntegrationTests.Tests.Preferences
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestNoPendingDatabaseChanges()
|
||||
{
|
||||
var pair = await PoolManager.GetServerClient();
|
||||
var server = pair.Server;
|
||||
var db = GetDb(server);
|
||||
Assert.That(async () => await db.HasPendingModelChanges(), Is.False,
|
||||
"The database has pending model changes. Add a new migration to apply them. See https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations");
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
|
||||
private static NetUserId NewUserId()
|
||||
{
|
||||
return new(Guid.NewGuid());
|
||||
|
||||
@@ -1534,6 +1534,12 @@ INSERT INTO player_round (players_id, rounds_id) VALUES ({players[player]}, {id}
|
||||
return time != null ? NormalizeDatabaseTime(time.Value) : time;
|
||||
}
|
||||
|
||||
public async Task<bool> HasPendingModelChanges()
|
||||
{
|
||||
await using var db = await GetDb();
|
||||
return db.DbContext.Database.HasPendingModelChanges();
|
||||
}
|
||||
|
||||
protected abstract Task<DbGuard> GetDb([CallerMemberName] string? name = null);
|
||||
|
||||
protected void LogDbOp(string? name)
|
||||
|
||||
Reference in New Issue
Block a user