11using Ardalis . GuardClauses ;
22using Raven . Client . Documents ;
3+ using Raven . Client . Documents . Operations ;
4+ using Raven . Client . Exceptions . Database ;
35using Raven . Client . ServerWide ;
46using Raven . Client . ServerWide . Operations ;
57using Serilog ;
@@ -25,21 +27,30 @@ public sealed class RavenDbTestProvider : DatabaseInstance
2527 public RavenDbTestProvider ( )
2628 {
2729 _documentStore = new DocumentStore { Database = DbName } ;
28- Container = new RavenDbBuilder ( ) . Build ( ) ;
30+ Container = new RavenDbBuilder ( )
31+ . WithImage ( "ravendb/ravendb:7.0-ubuntu-latest" )
32+ . Build ( ) ;
2933 }
3034
3135 protected override string Name => nameof ( RavenDbContainer ) ;
3236
33- protected override Task CheckDbReadinessAsync ( )
37+ protected override async Task CheckDbReadinessAsync ( )
3438 {
3539 Guard . Against . Null ( Container ) ;
3640
3741 var container = Container as RavenDbContainer ;
3842 _documentStore . Urls = [ container ? . GetConnectionString ( ) ] ;
3943 _documentStore . Initialize ( ) ;
40- _documentStore . Maintenance . Server . Send ( new CreateDatabaseOperation ( new DatabaseRecord ( DbName ) ) ) ;
4144
42- return Task . CompletedTask ;
45+ try
46+ {
47+ await _documentStore . Maintenance . ForDatabase ( DbName ) . SendAsync ( new GetStatisticsOperation ( ) ) ;
48+ }
49+ catch ( DatabaseDoesNotExistException )
50+ {
51+ var record = new DatabaseRecord ( DbName ) ;
52+ await _documentStore . Maintenance . Server . SendAsync ( new CreateDatabaseOperation ( record ) ) ;
53+ }
4354 }
4455
4556 protected override Task InitializeAdditionalAsync ( )
0 commit comments