feat/files-control #52

Open
notazof wants to merge 32 commits from feat/files-control into main
3 changed files with 38 additions and 10 deletions
Showing only changes of commit b75d0add7d - Show all commits

db testing

Paul Schneider 2026-09-07 20:02:56 +01:00
Signed by: notazof
GPG key ID: 1DD5D838E5343B06

View file

@ -1,20 +1,22 @@
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Yavsc.Models;
namespace Yavsc.Org.Tests.Mandatory
{
[Collection("Database")]
{[Collection("Database")]
[Trait("regression", "II")]
[Trait("dev", "wip")]
public class Database: IClassFixture<WebServerFixture>, IDisposable
{
readonly WebServerFixture _serverFixture;
readonly ITestOutputHelper output;
public Database(WebServerFixture serverFixture, ITestOutputHelper output)
readonly WebServerFixture _serverFixture;
public Database(ITestOutputHelper output, WebServerFixture _serverFixture)
{
this.output = output;
_serverFixture = serverFixture;
this._serverFixture = _serverFixture;
}
/// <summary>
@ -30,5 +32,13 @@ namespace Yavsc.Org.Tests.Mandatory
}
}
[Fact]
public void TestDatabaseMigration()
{
// Test logic goes here
_serverFixture.ResetAndMigrateDatabase();
}
}
}

View file

@ -189,6 +189,20 @@ public sealed class WebServerFixture : WebHostFixture
return app;
}
public void ResetAndMigrateDatabase()
{
using var scope = Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
db.Database.EnsureDeleted();
if (db.Database.IsRelational())
{
db.Database.Migrate();
return;
}
db.Database.EnsureCreated();
}
protected override async Task<WebApplication> ConfigurePipelineAsync(WebApplication app)
{
// The MSBuild target CopyYavscOrgStaticAssets in

View file

@ -11,6 +11,10 @@ namespace Yavsc.Migrations
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
var declarationDateDefaultSql = ActiveProvider == "Microsoft.EntityFrameworkCore.Sqlite"
? "CURRENT_TIMESTAMP"
: "LOCALTIMESTAMP";
migrationBuilder.CreateTable(
name: "Activities",
columns: table => new
@ -1484,7 +1488,7 @@ namespace Yavsc.Migrations
Platform = table.Column<string>(type: "text", nullable: true),
Version = table.Column<string>(type: "text", nullable: true),
DeviceOwnerId = table.Column<string>(type: "text", nullable: true),
DeclarationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "LOCALTIMESTAMP"),
DeclarationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: declarationDateDefaultSql),
LatestActivityUpdate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>