Skip to content

Commit

Permalink
Fix test concurrency issue (#2927)
Browse files Browse the repository at this point in the history
Make sure the (legacy) Northwind data source always gets created
with support for dynamic JSON and records as tuples.
  • Loading branch information
roji authored Nov 8, 2023
1 parent 4a7ef97 commit 0e40415
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ public class NorthwindQueryNpgsqlFixture<TModelCustomizer> : NorthwindQueryRelat
protected override ITestStoreFactory TestStoreFactory => NpgsqlNorthwindTestStoreFactory.Instance;
protected override Type ContextType => typeof(NorthwindNpgsqlContext);

static NorthwindQueryNpgsqlFixture()
{
// TODO: Switch to using NpgsqlDataSource
#pragma warning disable CS0618 // Type or member is obsolete
NpgsqlConnection.GlobalTypeMapper.EnableDynamicJsonMappings();
NpgsqlConnection.GlobalTypeMapper.EnableRecordsAsTuples();
#pragma warning restore CS0618 // Type or member is obsolete
}

public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
{
var optionsBuilder = base.AddOptions(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ public class NpgsqlNorthwindTestStoreFactory : NpgsqlTestStoreFactory
public static readonly string NorthwindConnectionString = NpgsqlTestStore.CreateConnectionString(Name);
public new static NpgsqlNorthwindTestStoreFactory Instance { get; } = new();

static NpgsqlNorthwindTestStoreFactory()
{
// TODO: Switch to using NpgsqlDataSource
#pragma warning disable CS0618 // Type or member is obsolete
NpgsqlConnection.GlobalTypeMapper.EnableDynamicJsonMappings();
NpgsqlConnection.GlobalTypeMapper.EnableRecordsAsTuples();
#pragma warning restore CS0618 // Type or member is obsolete
}

protected NpgsqlNorthwindTestStoreFactory()
{
}
Expand All @@ -15,4 +24,4 @@ public override TestStore GetOrCreate(string storeName)
TestEnvironment.PostgresVersion >= new Version(12, 0)
? @"CREATE COLLATION IF NOT EXISTS ""some-case-insensitive-collation"" (LOCALE = 'en-u-ks-primary', PROVIDER = icu, DETERMINISTIC = False);"
: null);
}
}

0 comments on commit 0e40415

Please sign in to comment.