Skip to content

Commit

Permalink
Fix tests for encrypted databases
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Oct 29, 2023
1 parent 38bb8d3 commit 4c8fc93
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions Tests/GRDBTests/DatabaseQueueInMemoryCopyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ final class DatabaseQueueInMemoryCopyTests: GRDBTestCase {

func test_inMemoryCopy() throws {
let source = try makeSourceDatabase()
let dbQueue = try DatabaseQueue.inMemoryCopy(fromPath: source.path)
let dbQueue = try DatabaseQueue.inMemoryCopy(
fromPath: source.path,
configuration: dbConfiguration)

// Test that content was faithfully copied
let stream = TestStream()
Expand All @@ -48,7 +50,9 @@ final class DatabaseQueueInMemoryCopyTests: GRDBTestCase {

func test_inMemoryCopy_write() throws {
let source = try makeSourceDatabase()
let dbQueue = try DatabaseQueue.inMemoryCopy(fromPath: source.path)
let dbQueue = try DatabaseQueue.inMemoryCopy(
fromPath: source.path,
configuration: dbConfiguration)

// The in-memory copy is writable (necessary for testing migrations)
try dbQueue.write { db in
Expand All @@ -70,7 +74,7 @@ final class DatabaseQueueInMemoryCopyTests: GRDBTestCase {

func test_inMemoryCopy_readOnly() throws {
let source = try makeSourceDatabase()
var config = Configuration()
var config = dbConfiguration!
config.readonly = true
let dbQueue = try DatabaseQueue.inMemoryCopy(fromPath: source.path, configuration: config)

Expand Down Expand Up @@ -116,7 +120,9 @@ final class DatabaseQueueInMemoryCopyTests: GRDBTestCase {

// …GRDB users can test the migrator on fixtures
let source = try makeSourceDatabase()
let dbQueue = try DatabaseQueue.inMemoryCopy(fromPath: source.path)
let dbQueue = try DatabaseQueue.inMemoryCopy(
fromPath: source.path,
configuration: dbConfiguration)

try migrator.migrate(dbQueue, upTo: "v2")
do {
Expand Down
14 changes: 10 additions & 4 deletions Tests/GRDBTests/DatabaseQueueTemporaryCopyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ final class DatabaseQueueTemporaryCopyTests: GRDBTestCase {

func test_temporaryCopy() throws {
let source = try makeSourceDatabase()
let dbQueue = try DatabaseQueue.temporaryCopy(fromPath: source.path)
let dbQueue = try DatabaseQueue.temporaryCopy(
fromPath: source.path,
configuration: dbConfiguration)

// Test that content was faithfully copied
let stream = TestStream()
Expand All @@ -48,7 +50,9 @@ final class DatabaseQueueTemporaryCopyTests: GRDBTestCase {

func test_temporaryCopy_write() throws {
let source = try makeSourceDatabase()
let dbQueue = try DatabaseQueue.temporaryCopy(fromPath: source.path)
let dbQueue = try DatabaseQueue.temporaryCopy(
fromPath: source.path,
configuration: dbConfiguration)

// The in-memory copy is writable (necessary for testing migrations)
try dbQueue.write { db in
Expand All @@ -70,7 +74,7 @@ final class DatabaseQueueTemporaryCopyTests: GRDBTestCase {

func test_temporaryCopy_readOnly() throws {
let source = try makeSourceDatabase()
var config = Configuration()
var config = dbConfiguration!
config.readonly = true
let dbQueue = try DatabaseQueue.temporaryCopy(fromPath: source.path, configuration: config)

Expand Down Expand Up @@ -116,7 +120,9 @@ final class DatabaseQueueTemporaryCopyTests: GRDBTestCase {

// …GRDB users can test the migrator on fixtures
let source = try makeSourceDatabase()
let dbQueue = try DatabaseQueue.temporaryCopy(fromPath: source.path)
let dbQueue = try DatabaseQueue.temporaryCopy(
fromPath: source.path,
configuration: dbConfiguration)

try migrator.migrate(dbQueue, upTo: "v2")
do {
Expand Down

0 comments on commit 4c8fc93

Please sign in to comment.