diff --git a/Directory.Packages.props b/Directory.Packages.props
index 39c7d4a..0446fc0 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -22,6 +22,7 @@
+
@@ -44,7 +45,6 @@
-
diff --git a/tests/AndreGoepel.Marten.Identity.IntegrationTests/AndreGoepel.Marten.Identity.IntegrationTests.csproj b/tests/AndreGoepel.Marten.Identity.IntegrationTests/AndreGoepel.Marten.Identity.IntegrationTests.csproj
index 91b3f3c..4b2ee99 100644
--- a/tests/AndreGoepel.Marten.Identity.IntegrationTests/AndreGoepel.Marten.Identity.IntegrationTests.csproj
+++ b/tests/AndreGoepel.Marten.Identity.IntegrationTests/AndreGoepel.Marten.Identity.IntegrationTests.csproj
@@ -11,9 +11,9 @@
+
-
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/tests/AndreGoepel.Marten.Identity.IntegrationTests/Infrastructure/MartenFixture.cs b/tests/AndreGoepel.Marten.Identity.IntegrationTests/Infrastructure/MartenFixture.cs
index f394883..9c88c5d 100644
--- a/tests/AndreGoepel.Marten.Identity.IntegrationTests/Infrastructure/MartenFixture.cs
+++ b/tests/AndreGoepel.Marten.Identity.IntegrationTests/Infrastructure/MartenFixture.cs
@@ -1,64 +1,38 @@
using AndreGoepel.Marten.Configuration;
-using JasperFx;
using Marten;
using Microsoft.Extensions.DependencyInjection;
-using Testcontainers.PostgreSql;
namespace AndreGoepel.Marten.Identity.IntegrationTests.Infrastructure;
///
-/// Spins up a Postgres container and a Marten
-/// configured the way the production host configures it (projections,
-/// schemas, identity wiring). Lives for the whole test collection so we
-/// pay the container start-up cost once.
+/// Configures the shared the way the
+/// production host configures Marten (identity projections/schemas) via the package's documented
+/// ConfigureStore/OnStoreInitializedAsync extension hooks, instead of re-implementing
+/// the Postgres container lifecycle.
///
-public sealed class MartenFixture : IAsyncLifetime
+public sealed class MartenFixture : AndreGoepel.Marten.Testing.MartenFixture
{
- private PostgreSqlContainer _container = null!;
-
- public IDocumentStore Store { get; private set; } = null!;
-
- /// An backed by , resolved
- /// through the public DI registration rather than the package's internal type.
+ /// An backed by ,
+ /// resolved through the public DI registration rather than the package's internal type.
public ISettingsStore SettingsStore { get; private set; } = null!;
- // Pin the Postgres image by digest (not a mutable tag) so the test/CI
- // environment can't be fed a different image behind the same tag (#37).
- // Update via Dependabot/manual bump together with the digest.
- private const string PostgresImage =
- "postgres:16-alpine@sha256:e013e867e712fec275706a6c51c966f0bb0c93cfa8f51000f85a15f9865a28cb";
+ protected override void ConfigureStore(StoreOptions options) => options.InitializeIdentity();
- public async ValueTask InitializeAsync()
+ protected override async ValueTask OnStoreInitializedAsync()
{
- _container = new PostgreSqlBuilder(PostgresImage).Build();
- await _container.StartAsync();
-
- Store = DocumentStore.For(opts =>
- {
- opts.Connection(_container.GetConnectionString());
- opts.InitializeIdentity();
- opts.AutoCreateSchemaObjects = AutoCreate.All;
- });
-
var services = new ServiceCollection();
services.AddSingleton(Store);
services.AddMartenConfiguration();
SettingsStore = services.BuildServiceProvider().GetRequiredService();
}
- public async ValueTask DisposeAsync()
- {
- await Store.DisposeAsync();
- await _container.DisposeAsync();
- }
-
///
- /// Wipes documents and event streams between tests without dropping
- /// the schema (the schema rebuild is the slow part).
+ /// Wipes documents and event streams between tests without dropping the schema (the schema
+ /// rebuild is the slow part).
///
- public async Task ResetAsync(CancellationToken cancellationToken = default)
+ public override async Task ResetAsync(CancellationToken cancellationToken = default)
{
- await Store.Advanced.Clean.DeleteAllDocumentsAsync(cancellationToken);
+ await base.ResetAsync(cancellationToken);
await Store.Advanced.Clean.DeleteAllEventDataAsync(cancellationToken);
}
}
diff --git a/tests/AndreGoepel.Marten.Identity.IntegrationTests/packages.lock.json b/tests/AndreGoepel.Marten.Identity.IntegrationTests/packages.lock.json
index a58f01a..abab3c6 100644
--- a/tests/AndreGoepel.Marten.Identity.IntegrationTests/packages.lock.json
+++ b/tests/AndreGoepel.Marten.Identity.IntegrationTests/packages.lock.json
@@ -2,6 +2,17 @@
"version": 2,
"dependencies": {
"net10.0": {
+ "AndreGoepel.Marten.Testing": {
+ "type": "Direct",
+ "requested": "[1.0.0, )",
+ "resolved": "1.0.0",
+ "contentHash": "BjCrRNv7Y6phechbDHpfErJid3mJ9JSBQtu+4Wrpc6Al2hrGUQU3/wHe63MIDZGpi+tMFyMsI/PYMrsKQffQsA==",
+ "dependencies": {
+ "Marten": "9.19.0",
+ "Testcontainers.PostgreSql": "4.13.0",
+ "xunit.v3.extensibility.core": "3.2.2"
+ }
+ },
"coverlet.collector": {
"type": "Direct",
"requested": "[10.0.1, )",
@@ -27,15 +38,6 @@
"Castle.Core": "5.1.1"
}
},
- "Testcontainers.PostgreSql": {
- "type": "Direct",
- "requested": "[4.13.0, )",
- "resolved": "4.13.0",
- "contentHash": "2ow4AE8drI9iA9Fr4ycAPusXPB1lJfQyyNONSMLE/XqLpm8VuNAh3pK38fOjkOWtTrnD03s4hAIdl4036Ik69A==",
- "dependencies": {
- "Testcontainers": "4.13.0"
- }
- },
"xunit.runner.visualstudio": {
"type": "Direct",
"requested": "[3.1.5, )",
@@ -318,6 +320,14 @@
"SharpZipLib": "1.4.2"
}
},
+ "Testcontainers.PostgreSql": {
+ "type": "Transitive",
+ "resolved": "4.13.0",
+ "contentHash": "2ow4AE8drI9iA9Fr4ycAPusXPB1lJfQyyNONSMLE/XqLpm8VuNAh3pK38fOjkOWtTrnD03s4hAIdl4036Ik69A==",
+ "dependencies": {
+ "Testcontainers": "4.13.0"
+ }
+ },
"Weasel.Core": {
"type": "Transitive",
"resolved": "9.17.0",