I'm pretty new to Swift, more specifically on Kitura. I'm using SwiftKueryPostgresql to handle communication with database.
I'm writting an ORM library for a specific project. I'm testing my connection like this (as I understood from documentation) :
import Foundation
import SwiftKuery
import SwiftKueryPostgreSQL
import XCTest
@testable import myprojet
final class project_ormTests: XCTestCase {
var context: Context? = Context(pool: PostgreSQLConnection.createPool(host: "localhost", port: 5432, options: [.databaseName("project"), .userName("myproject"), .password("")], poolOptions: ConnectionPoolOptions(initialCapacity: 3)).getConnection())
}
func testConnection() {
XCTAssertNotNil(context)
}
static var allTests = [
("testConnection", testConnection),
]
}
My class Context :
public class Context {
private let pool : Connection
public init?(pool : Connection?) {
guard pool != nil else { return nil }
self.pool = pool!
}
}
When I run testConnection()
on xcode, I reach SwiftKuery/ConnectionPool.swift on line 129 with this error
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
What am I doing wrong ? Is there something I missed ? I really have no idea what to do...
Here's my Package.swift if it can help
import PackageDescription
let package = Package(
name: "project",
products: [
.library(
name: "projet",
targets: ["project"]),
],
dependencies: [
.package(url: "https://github.com/IBM-Swift/Swift-Kuery-PostgreSQL.git", from: "1.2.0")
],
targets:[
.target(
name: "project",
dependencies: ["SwiftKueryPostgreSQL"]),
.testTarget(
name: "projectTests",
dependencies: ["project"]),
]
)
Thank you