Skip to content

Commit

Permalink
fix(StorageBaseTest): Fix dropping created databases
Browse files Browse the repository at this point in the history
  • Loading branch information
unchase committed Aug 31, 2021
1 parent 757048a commit 8c818fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/MiniProfiler.Tests/Storage/SqlServerStorageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Dispose()
{
if (!ShouldSkip)
{
Storage.DropSchema();
Storage?.DropSchema(true);
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/MiniProfiler.Tests/Storage/StorageBaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,16 @@ public static void CreateSchema(this IAsyncStorage storage)
/// Drops the tables for this storage provider.
/// </summary>
/// <param name="storage">The storage to drop schema for.</param>
public static void DropSchema(this IAsyncStorage storage)
/// <param name="withSchema">Drop tables with schema name.</param>
public static void DropSchema(this IAsyncStorage storage, bool withSchema = false)
{
if (storage is DatabaseStorageBase dbs && storage is IDatabaseStorageConnectable dbsc)
{
using (var conn = dbsc.GetConnection())
{
conn.Execute("Drop Table " + dbs.MiniProfilerClientTimingsTable);
conn.Execute("Drop Table " + dbs.MiniProfilerTimingsTable);
conn.Execute("Drop Table " + dbs.MiniProfilersTable);
conn.Execute($"Drop Table {(withSchema ? $"{dbs.SchemaName}" : string.Empty)}{dbs.MiniProfilerClientTimingsTable}");
conn.Execute($"Drop Table {(withSchema ? $"{dbs.SchemaName}" : string.Empty)}{dbs.MiniProfilerTimingsTable}");
conn.Execute($"Drop Table {(withSchema ? $"{dbs.SchemaName}" : string.Empty)}{dbs.MiniProfilersTable}");
}
}
}
Expand Down

0 comments on commit 8c818fe

Please sign in to comment.