Skip to content

Commit 5b75171

Browse files
test: Creates reproducer test
1 parent 6f0fc05 commit 5b75171

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Tests/IntegrationTests/PostgresNIOTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ final class PostgresNIOTests: XCTestCase {
7676
XCTAssertEqual(rows.count, 1)
7777
XCTAssertEqual(try rows.first?.decode(String.self, context: .default).contains("PostgreSQL"), true)
7878
}
79+
80+
func testSimpleQueryWithQuotes() {
81+
var conn: PostgresConnection?
82+
XCTAssertNoThrow(conn = try PostgresConnection.test(on: eventLoop).wait())
83+
defer { XCTAssertNoThrow( try conn?.close().wait() ) }
84+
85+
var receivedNotifications: [PostgresMessage.NotificationResponse] = []
86+
conn?.addListener(channel: "default") { context, notification in
87+
receivedNotifications.append(notification)
88+
}
89+
XCTAssertNoThrow(_ = try conn?.simpleQuery("LISTEN \"default\"").wait())
90+
XCTAssertNoThrow(_ = try conn?.simpleQuery("NOTIFY \"default\"").wait())
91+
// Notifications are asynchronous, so we should run at least one more query to make sure we'll have received the notification response by then
92+
XCTAssertNoThrow(_ = try conn?.simpleQuery("SELECT 1").wait())
93+
XCTAssertEqual(receivedNotifications.count, 1)
94+
XCTAssertEqual(receivedNotifications.first?.channel, "default")
95+
XCTAssertEqual(receivedNotifications.first?.payload, "")
96+
}
7997

8098
func testQueryVersion() {
8199
var conn: PostgresConnection?

0 commit comments

Comments
 (0)