Skip to content

Commit 82b32f9

Browse files
committed
Do not actually connect to target in -WhatIf mode seeding.
1 parent 8a054b3 commit 82b32f9

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

PSql.Deploy.Engine.Tests/Seeds/WhatIfSeedTargetConnectionTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ public void Construct_NullConnection()
3232
});
3333
}
3434

35+
[Test]
36+
public async Task OpenAsync()
37+
{
38+
_logger.Setup(l => l.Log("", 0, 0, 0, "Would open connection."));
39+
40+
await _outer.OpenAsync(Cancellation.Token);
41+
}
42+
3543
[Test]
3644
public async Task PrepareAsync()
3745
{

PSql.Deploy.Engine/Core/WhatIfTargetConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public ISqlMessageLogger Logger
4343
=> _connection.Logger;
4444

4545
/// <inheritdoc/>
46-
public Task OpenAsync(CancellationToken cancellation)
46+
public virtual Task OpenAsync(CancellationToken cancellation)
4747
=> _connection.OpenAsync(cancellation);
4848

4949
/// <inheritdoc/>

PSql.Deploy.Engine/Seeds/WhatIfSeedTargetConnection.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ public WhatIfSeedTargetConnection(ISeedTargetConnection connection)
1919
=> (ISeedTargetConnection) base.UnderlyingConnection;
2020
#endif
2121

22+
/// <inheritdoc/>
23+
public override Task OpenAsync(CancellationToken cancellation)
24+
{
25+
Log("Would open connection.");
26+
return Task.CompletedTask;
27+
}
28+
2229
/// <inheritdoc/>
2330
public Task PrepareAsync(Guid runId, int workerId, CancellationToken cancellation = default)
2431
{

0 commit comments

Comments
 (0)