@@ -659,22 +659,6 @@ final class PostgresNIOTests: XCTestCase {
659659 }
660660 }
661661
662- func testJSONBConvertible( ) {
663- struct Object : PostgresJSONBCodable {
664- let foo : Int
665- let bar : Int
666- }
667-
668- XCTAssertEqual ( Object . postgresDataType, . jsonb)
669-
670- let postgresData = Object ( foo: 1 , bar: 2 ) . postgresData
671- XCTAssertEqual ( postgresData? . type, . jsonb)
672-
673- let object = Object ( postgresData: postgresData!)
674- XCTAssertEqual ( object? . foo, 1 )
675- XCTAssertEqual ( object? . bar, 2 )
676- }
677-
678662 func testRemoteTLSServer( ) {
679663 // postgres://uymgphwj:
[email protected] :5432/uymgphwj
680664 var conn : PostgresConnection ?
@@ -899,38 +883,6 @@ final class PostgresNIOTests: XCTestCase {
899883 XCTAssertEqual ( rows? . first? . column ( " int " ) ? . uint8, 5 )
900884 }
901885
902- func testMessageDecoder( ) {
903- let sample : [ UInt8 ] = [
904- 0x52 , // R - authentication
905- 0x00 , 0x00 , 0x00 , 0x0C , // length = 12
906- 0x00 , 0x00 , 0x00 , 0x05 , // md5
907- 0x01 , 0x02 , 0x03 , 0x04 , // salt
908- 0x4B , // B - backend key data
909- 0x00 , 0x00 , 0x00 , 0x0C , // length = 12
910- 0x05 , 0x05 , 0x05 , 0x05 , // process id
911- 0x01 , 0x01 , 0x01 , 0x01 , // secret key
912- ]
913- var input = ByteBufferAllocator ( ) . buffer ( capacity: 0 )
914- input. writeBytes ( sample)
915-
916- let output : [ PostgresMessage ] = [
917- PostgresMessage ( identifier: . authentication, bytes: [
918- 0x00 , 0x00 , 0x00 , 0x05 ,
919- 0x01 , 0x02 , 0x03 , 0x04 ,
920- ] ) ,
921- PostgresMessage ( identifier: . backendKeyData, bytes: [
922- 0x05 , 0x05 , 0x05 , 0x05 ,
923- 0x01 , 0x01 , 0x01 , 0x01 ,
924- ] )
925- ]
926- XCTAssertNoThrow ( try XCTUnwrap ( ByteToMessageDecoderVerifier . verifyDecoder (
927- inputOutputPairs: [ ( input, output) ] ,
928- decoderFactory: {
929- PostgresMessageDecoder ( )
930- }
931- ) ) )
932- }
933-
934886 func testPreparedQuery( ) {
935887 var conn : PostgresConnection ?
936888 XCTAssertNoThrow ( conn = try PostgresConnection . test ( on: eventLoop) . wait ( ) )
@@ -1135,62 +1087,6 @@ final class PostgresNIOTests: XCTestCase {
11351087 XCTAssertEqual ( rows? . first? . column ( " min64 " ) ? . int64, . min)
11361088 XCTAssertEqual ( rows? . first? . column ( " max64 " ) ? . int64, . max)
11371089 }
1138-
1139- // https://github.com/vapor/postgres-nio/issues/126
1140- func testCustomJSONEncoder( ) {
1141- let previousDefaultJSONEncoder = PostgresNIO . _defaultJSONEncoder
1142- defer {
1143- PostgresNIO . _defaultJSONEncoder = previousDefaultJSONEncoder
1144- }
1145- final class CustomJSONEncoder : PostgresJSONEncoder {
1146- var didEncode = false
1147- func encode< T> ( _ value: T ) throws -> Data where T : Encodable {
1148- self . didEncode = true
1149- return try JSONEncoder ( ) . encode ( value)
1150- }
1151- }
1152- struct Object : Codable {
1153- var foo : Int
1154- var bar : Int
1155- }
1156- let customJSONEncoder = CustomJSONEncoder ( )
1157- PostgresNIO . _defaultJSONEncoder = customJSONEncoder
1158- XCTAssertNoThrow ( try PostgresData ( json: Object ( foo: 1 , bar: 2 ) ) )
1159- XCTAssert ( customJSONEncoder. didEncode)
1160-
1161- let customJSONBEncoder = CustomJSONEncoder ( )
1162- PostgresNIO . _defaultJSONEncoder = customJSONBEncoder
1163- XCTAssertNoThrow ( try PostgresData ( json: Object ( foo: 1 , bar: 2 ) ) )
1164- XCTAssert ( customJSONBEncoder. didEncode)
1165- }
1166-
1167- // https://github.com/vapor/postgres-nio/issues/126
1168- func testCustomJSONDecoder( ) {
1169- let previousDefaultJSONDecoder = PostgresNIO . _defaultJSONDecoder
1170- defer {
1171- PostgresNIO . _defaultJSONDecoder = previousDefaultJSONDecoder
1172- }
1173- final class CustomJSONDecoder : PostgresJSONDecoder {
1174- var didDecode = false
1175- func decode< T> ( _ type: T . Type , from data: Data ) throws -> T where T : Decodable {
1176- self . didDecode = true
1177- return try JSONDecoder ( ) . decode ( type, from: data)
1178- }
1179- }
1180- struct Object : Codable {
1181- var foo : Int
1182- var bar : Int
1183- }
1184- let customJSONDecoder = CustomJSONDecoder ( )
1185- PostgresNIO . _defaultJSONDecoder = customJSONDecoder
1186- XCTAssertNoThrow ( try PostgresData ( json: Object ( foo: 1 , bar: 2 ) ) . json ( as: Object . self) )
1187- XCTAssert ( customJSONDecoder. didDecode)
1188-
1189- let customJSONBDecoder = CustomJSONDecoder ( )
1190- PostgresNIO . _defaultJSONDecoder = customJSONBDecoder
1191- XCTAssertNoThrow ( try PostgresData ( json: Object ( foo: 1 , bar: 2 ) ) . json ( as: Object . self) )
1192- XCTAssert ( customJSONBDecoder. didDecode)
1193- }
11941090}
11951091
11961092let isLoggingConfigured : Bool = {
0 commit comments