Skip to content

Commit

Permalink
Fix totally unnecessary preconditionFailure in PSQLEventsHandler (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianfett committed Jun 13, 2024
1 parent ee669e9 commit 5c26876
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 1 addition & 3 deletions Sources/PostgresNIO/New/PSQLEventsHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ final class PSQLEventsHandler: ChannelInboundHandler {
case .authenticated:
break
}
case TLSUserEvent.shutdownCompleted:
break
default:
preconditionFailure()
context.fireUserInboundEventTriggered(event)
}
}

Expand Down
9 changes: 9 additions & 0 deletions Tests/PostgresNIOTests/New/PostgresConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,15 @@ class PostgresConnectionTests: XCTestCase {
}
}

func testWeDontCrashOnUnexpectedChannelEvents() async throws {
let (connection, channel) = try await self.makeTestConnectionWithAsyncTestingChannel()

enum MyEvent {
case pleaseDontCrash
}
channel.pipeline.fireUserInboundEventTriggered(MyEvent.pleaseDontCrash)
}

func testSerialExecutionOfSamePreparedStatement() async throws {
let (connection, channel) = try await self.makeTestConnectionWithAsyncTestingChannel()

Expand Down

0 comments on commit 5c26876

Please sign in to comment.