Skip to content

Commit

Permalink
fix db hash in recreate issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaddix committed Mar 8, 2024
1 parent ff00d3c commit 063c90c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/MccSoft.IntegreSql.EF/IntegreSqlClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public async Task<GetDatabaseDto> GetTestDatabase(string hash)
/// Returns test database to a pool (which allows consequent tests to reuse this database).
/// This method (contrary to <see cref="ReturnTestDatabase"/>) will tell IntegreSQL to cleanup the database.
/// </summary>
public async Task ReleaseTestDatabase(string hash, int id)
public async Task RecreateTestDatabase(string hash, int id)
{
HttpResponseMessage response;
try
Expand Down Expand Up @@ -218,7 +218,7 @@ public async Task ReleaseTestDatabase(string hash, int id)
/// If you don't want to clean it up, just don't use this function.
/// Dirty databases are automatically deleted by IntegreSQL once database number exceeds a certain limit (500 by default).
///
/// Consider using <see cref="ReleaseTestDatabase"/> if you want the DB to be deleted/recreated by IntegreSQL
/// Consider using <see cref="RecreateTestDatabase"/> if you want the DB to be deleted/recreated by IntegreSQL
/// </summary>
public async Task ReturnTestDatabase(string hash, int id)
{
Expand Down
2 changes: 1 addition & 1 deletion src/MccSoft.IntegreSql.EF/MccSoft.IntegreSql.EF.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>0.10.2</Version>
<Version>0.10.3</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>MCC Soft</Authors>
<Description>OpenIddict extension to support Auth code flow fo built-in ASP.Net identity providers</Description>
Expand Down
5 changes: 1 addition & 4 deletions src/MccSoft.IntegreSql.EF/NpgsqlDatabaseInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public override async Task RemoveDatabase(string connectionString)
{
var connectionStringInfo = ConnectionStringInfos[connectionString];

await _integreSqlClient.ReleaseTestDatabase(
await _integreSqlClient.RecreateTestDatabase(
connectionStringInfo.Hash,
connectionStringInfo.Id
);
Expand Down Expand Up @@ -220,9 +220,6 @@ protected override void PerformBasicSeedingOperations(DbContext dbContext)

private string GetConnectionString(Config databaseConfig, string hash, int id)
{
if (UseMd5Hash)
hash = Md5Hasher.CreateMD5(hash);

var builder = new NpgsqlConnectionStringBuilder()
{
Host = ConnectionStringOverride?.Host ?? databaseConfig.Host,
Expand Down
6 changes: 5 additions & 1 deletion tests/ExampleWeb.UnitTests/UnitTestSimplified.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public UnitTestSimplified()
// This is needed if you run tests NOT inside the container.
// 5434 is the public port number of Postgresql instance
connectionStringOverride: new() { Host = "localhost", Port = 5434, }
);
)
{
DropDatabaseOnRemove = true,
};
_dbContextOptions = _databaseInitializer
.CreateDatabaseGetDbContextOptionsBuilderSync<ExampleDbContext>()
.Options;
Expand All @@ -31,6 +34,7 @@ public ExampleDbContext CreateDbContext()
[Fact]
public async Task Test1()
{
var connectionString = CreateDbContext().Database.GetConnectionString();
var service = new UserService(CreateDbContext());
var users = await service.GetUsers();
Assert.Equal(new[] { "John", "Bill" }, users);
Expand Down

0 comments on commit 063c90c

Please sign in to comment.