Skip to content

Commit

Permalink
Add a test for generating series with simple query
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Aug 26, 2024
1 parent e403409 commit 25a69ec
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Tests/IntegrationTests/AsyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ final class AsyncPostgresConnectionTests: XCTestCase {
}
}

func testSelect10kRowsSimpleQuery() async throws {
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer { XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully()) }
let eventLoop = eventLoopGroup.next()

let start = 1
let end = 10000

try await withTestConnection(on: eventLoop) { connection in
let rows = try await connection.__simpleQuery("SELECT generate_series(\(start), \(end));", logger: .psqlTest)
var counter = 0
for try await row in rows {
let element = try row.decode(Int.self)
XCTAssertEqual(element, counter + 1)
counter += 1
}

XCTAssertEqual(counter, end)
}
}

func testSelectActiveConnection() async throws {
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer { XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully()) }
Expand Down

0 comments on commit 25a69ec

Please sign in to comment.