Skip to content

Commit

Permalink
[release/8.0; Test only] Make Cosmos EnsureCreated tests run async on…
Browse files Browse the repository at this point in the history
…ly (#32483)

Fixes #32481
  • Loading branch information
ajcvickers authored Dec 1, 2023
1 parent 141740f commit 3ebc2ca
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,33 @@ public class CosmosDatabaseCreatorTest
//new object[] { false }
};

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public async Task EnsureCreated_returns_true_when_database_does_not_exist(bool async)
[ConditionalFact]
public async Task EnsureCreated_returns_true_when_database_does_not_exist()
{
await using var testDatabase = CosmosTestStore.Create("NonExisting");
try
{
using var context = new BloggingContext(testDatabase);
var creator = context.GetService<IDatabaseCreator>();

Assert.True(async ? await creator.EnsureCreatedAsync() : creator.EnsureCreated());
Assert.True(await creator.EnsureCreatedAsync());
}
finally
{
testDatabase.Initialize(testDatabase.ServiceProvider, () => new BloggingContext(testDatabase));
}
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public async Task EnsureCreated_returns_true_when_database_exists_but_collections_do_not(bool async)
[ConditionalFact]
public async Task EnsureCreated_returns_true_when_database_exists_but_collections_do_not()
{
await using var testDatabase = CosmosTestStore.Create("EnsureCreatedTest");
try
{
using var context = new BloggingContext(testDatabase);
var creator = context.GetService<IDatabaseCreator>();

Assert.True(async ? await creator.EnsureCreatedAsync() : creator.EnsureCreated());
Assert.True(await creator.EnsureCreatedAsync());
}
finally
{
Expand Down

0 comments on commit 3ebc2ca

Please sign in to comment.