Skip to content

Commit

Permalink
tests for postgre with schemas name
Browse files Browse the repository at this point in the history
  • Loading branch information
qcplus committed Jul 25, 2023
1 parent 8eeec89 commit 66c9658
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions Respawn.DatabaseTests/PostgresTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,30 @@ public async Task ShouldIgnoreTables()
_database.ExecuteScalar<int>("SELECT COUNT(1) FROM bar").ShouldBe(0);
}

[SkipOnCI]
public async Task ShouldIgnoreTablesIfSchemaSpecified()
{
await _database.ExecuteAsync("create schema eggs");
await _database.ExecuteAsync("create table eggs.foo (Value int)");
await _database.ExecuteAsync("create table eggs.bar (Value int)");

for (int i = 0; i < 100; i++)
{
await _database.ExecuteAsync("INSERT INTO \"eggs\".\"foo\" VALUES (@0)", i);
await _database.ExecuteAsync("INSERT INTO \"eggs\".\"bar\" VALUES (@0)", i);
}

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres,
TablesToIgnore = new Table[] { new Table("eggs", "foo") }
});
await checkpoint.ResetAsync(_connection);

_database.ExecuteScalar<int>("SELECT COUNT(1) FROM eggs.foo").ShouldBe(100);
_database.ExecuteScalar<int>("SELECT COUNT(1) FROM eggs.bar").ShouldBe(0);
}

[SkipOnCI]
public async Task ShouldIncludeTables()
{
Expand All @@ -120,6 +144,30 @@ public async Task ShouldIncludeTables()
_database.ExecuteScalar<int>("SELECT COUNT(1) FROM bar").ShouldBe(100);
}

[SkipOnCI]
public async Task ShouldIncludeTablesIfSchemaSpecified()
{
await _database.ExecuteAsync("create schema eggs");
await _database.ExecuteAsync("create table eggs.foo (Value int)");
await _database.ExecuteAsync("create table eggs.bar (Value int)");

for (int i = 0; i < 100; i++)
{
await _database.ExecuteAsync("INSERT INTO \"eggs\".\"foo\" VALUES (@0)", i);
await _database.ExecuteAsync("INSERT INTO \"eggs\".\"bar\" VALUES (@0)", i);
}

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres,
TablesToInclude = new Table[] { new Table("eggs", "foo") }
});
await checkpoint.ResetAsync(_connection);

_database.ExecuteScalar<int>("SELECT COUNT(1) FROM eggs.foo").ShouldBe(0);
_database.ExecuteScalar<int>("SELECT COUNT(1) FROM eggs.bar").ShouldBe(100);
}

[SkipOnCI]
public async Task ShouldHandleRelationships()
{
Expand Down

0 comments on commit 66c9658

Please sign in to comment.