diff --git a/src/Sample/Program.cs b/src/Sample/Program.cs index 90bc3e8..86cd598 100644 --- a/src/Sample/Program.cs +++ b/src/Sample/Program.cs @@ -1,4 +1,5 @@ using System; +using Microsoft.Data.Sqlite; namespace SQLiteSampleApplication { @@ -55,7 +56,7 @@ static void TemporaryFileDb() static void PermanentFileDb() { - Microsoft.Data.Sqlite.SqliteConnection connection = new("Data Source=dbup.db"); + SqliteConnection connection = new("Data Source=dbup.db"); using (var database = new DbUp.SQLite.Helpers.SharedConnection(connection)) { diff --git a/src/Tests/SQLiteSupportTests.cs b/src/Tests/SQLiteSupportTests.cs index 0b32f7d..c861ec1 100644 --- a/src/Tests/SQLiteSupportTests.cs +++ b/src/Tests/SQLiteSupportTests.cs @@ -1,17 +1,16 @@ -using Microsoft.Data.Sqlite; -using Shouldly; +using Shouldly; using Xunit; namespace DbUp.SQLite.Tests { public class SQLiteSupportTests { - static readonly string dbFilePath = Path.Combine(Environment.CurrentDirectory, "test.db"); + static readonly string DbFilePath = Path.Combine(Environment.CurrentDirectory, "test.db"); [Fact] public void CanUseSQLite() { - var connectionString = $"Data Source={dbFilePath}"; + var connectionString = $"Data Source={DbFilePath}"; var upgrader = DeployChanges.To .SQLiteDatabase(connectionString) @@ -23,5 +22,28 @@ public void CanUseSQLite() result.Error.ShouldBe(null); result.Successful.ShouldBe(true); } + + /// + /// Test for https://github.com/DbUp/dbup-sqlite/issues/2 + /// + [Fact] + public void DoesNotExhibitSafeHandleError() + { + var connectionString = "Data source=:memory:"; + + var upgrader = + DeployChanges.To + .SQLiteDatabase(connectionString) + .WithScript("Script001", @" +create table test ( + contact_id INTEGER PRIMARY KEY +); +") + .LogScriptOutput() + .LogToConsole() + .Build(); + var result = upgrader.PerformUpgrade(); + result.Successful.ShouldBeTrue(); + } } } diff --git a/src/dbup-sqlite/Helpers/InMemorySQLiteDatabase.cs b/src/dbup-sqlite/Helpers/InMemorySQLiteDatabase.cs index 8e3dfb3..c58e744 100644 --- a/src/dbup-sqlite/Helpers/InMemorySQLiteDatabase.cs +++ b/src/dbup-sqlite/Helpers/InMemorySQLiteDatabase.cs @@ -23,6 +23,8 @@ public InMemorySQLiteDatabase() { DataSource = ":memory:", DefaultTimeout = 5, + Mode = SqliteOpenMode.Memory, + ConnectionString = "PRAGMA encoding='UTF-16'; PRAGMA journal_mode='MEMORY';" }; ConnectionString = connectionStringBuilder.ToString();