Skip to content

Commit 3cb5c74

Browse files
committed
Updated tests
1 parent cc6e56a commit 3cb5c74

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

Package.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import PackageDescription
44

55
let package = Package(
66
name: "Pgvector",
7+
platforms: [
8+
.macOS(.v10_15),
9+
],
710
products: [
811
.library(
912
name: "Pgvector",
1013
targets: ["Pgvector"]),
1114
],
1215
dependencies: [
13-
.package(url: "https://github.com/codewinsdotcom/PostgresClientKit", from: "1.0.0"),
14-
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.8.0"),
16+
.package(url: "https://github.com/codewinsdotcom/PostgresClientKit", from: "1.5.0"),
17+
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.24.0"),
1518
],
1619
targets: [
1720
.target(

Tests/PgvectorTests/PgvectorTests.swift

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import XCTest
1+
import Testing
22
import Foundation
33
import PostgresClientKit
44
import PostgresNIO
55
import NIOPosix
66
import Logging
77
@testable import Pgvector
88

9-
final class PgvectorTests: XCTestCase {
10-
func testPostgresClientKit() throws {
9+
final class PgvectorTests {
10+
@Test func postgresClientKit() throws {
1111
var configuration = PostgresClientKit.ConnectionConfiguration()
1212
configuration.database = "pgvector_swift_test"
1313
configuration.ssl = false
@@ -48,20 +48,16 @@ final class PgvectorTests: XCTestCase {
4848
try statement.execute()
4949
}
5050

51-
func testPostgresNIO() async throws {
51+
@Test func postgresNIO() async throws {
5252
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
5353
let logger = Logger(label: "postgres-logger")
5454

5555
let config = PostgresConnection.Configuration(
56-
connection: .init(
57-
host: "localhost",
58-
port: 5432
59-
),
60-
authentication: .init(
61-
username: ProcessInfo.processInfo.environment["USER"]!,
62-
database: "pgvector_swift_test",
63-
password: nil
64-
),
56+
host: "localhost",
57+
port: 5432,
58+
username: ProcessInfo.processInfo.environment["USER"]!,
59+
password: nil,
60+
database: "pgvector_swift_test",
6561
tls: .disable
6662
)
6763

@@ -73,21 +69,21 @@ final class PgvectorTests: XCTestCase {
7369
)
7470

7571
try await connection.query("CREATE EXTENSION IF NOT EXISTS vector", logger: logger)
76-
try await connection.query("DROP TABLE IF EXISTS items", logger: logger)
77-
try await connection.query("CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))", logger: logger)
72+
try await connection.query("DROP TABLE IF EXISTS nio_items", logger: logger)
73+
try await connection.query("CREATE TABLE nio_items (id bigserial PRIMARY KEY, embedding vector(3))", logger: logger)
7874

7975
let embedding1 = "[1,1,1]"
8076
let embedding2 = "[2,2,2]"
8177
let embedding3 = "[1,1,2]"
82-
try await connection.query("INSERT INTO items (embedding) VALUES (\(embedding1)::vector), (\(embedding2)::vector), (\(embedding3)::vector)", logger: logger)
78+
try await connection.query("INSERT INTO nio_items (embedding) VALUES (\(embedding1)::vector), (\(embedding2)::vector), (\(embedding3)::vector)", logger: logger)
8379

8480
let embedding = "[1,1,1]"
85-
let rows = try await connection.query("SELECT id, embedding::text FROM items ORDER BY embedding <-> \(embedding)::vector LIMIT 5", logger: logger)
81+
let rows = try await connection.query("SELECT id, embedding::text FROM nio_items ORDER BY embedding <-> \(embedding)::vector LIMIT 5", logger: logger)
8682
for try await row in rows {
8783
print(row)
8884
}
8985

90-
try await connection.query("CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 1)", logger: logger)
86+
try await connection.query("CREATE INDEX ON nio_items USING ivfflat (embedding vector_l2_ops) WITH (lists = 1)", logger: logger)
9187

9288
try await connection.close()
9389
}

0 commit comments

Comments
 (0)