@@ -2,6 +2,7 @@ import Clocks
22import ConcurrencyExtras
33import CustomDump
44import InlineSnapshotTesting
5+ import IssueReporting
56import TestHelpers
67import XCTest
78
@@ -241,7 +242,7 @@ final class RealtimeTests: XCTestCase {
241242
242243 // Wait for the timeout for rejoining.
243244 await testClock. advance ( by: . seconds( timeoutInterval) )
244-
245+
245246 // Wait for the retry delay (base delay is 1.0s, but we need to account for jitter)
246247 // The retry delay is calculated as: baseDelay * pow(2, attempt-1) + jitter
247248 // For attempt 2: 1.0 * pow(2, 1) = 2.0s + jitter (up to ±25% = ±0.5s)
@@ -443,7 +444,7 @@ final class RealtimeTests: XCTestCase {
443444
444445 await testClock. advance ( by: . seconds( timeoutInterval) )
445446 subscribeTask. cancel ( )
446-
447+
447448 do {
448449 try await subscribeTask. value
449450 XCTFail ( " Expected cancellation error but got success " )
@@ -575,51 +576,6 @@ final class RealtimeTests: XCTestCase {
575576 XCTAssertEqual ( heartbeatStatuses. value, [ . sent, . timeout] )
576577 }
577578
578- func testBroadcastWithHTTP( ) async throws {
579- await http. when {
580- $0. url. path. hasSuffix ( " broadcast " )
581- } return: { _ in
582- HTTPResponse (
583- data: " {} " . data ( using: . utf8) !,
584- response: HTTPURLResponse (
585- url: self . sut. broadcastURL,
586- statusCode: 200 ,
587- httpVersion: nil ,
588- headerFields: nil
589- ) !
590- )
591- }
592-
593- let channel = sut. channel ( " public:messages " ) {
594- $0. broadcast. acknowledgeBroadcasts = true
595- }
596-
597- try await channel. broadcast ( event: " test " , message: [ " value " : 42 ] )
598-
599- let request = await http. receivedRequests. last
600- assertInlineSnapshot ( of: request? . urlRequest, as: . raw( pretty: true ) ) {
601- """
602- POST http://localhost:54321/realtime/v1/api/broadcast
603- Authorization: Bearer custom.access.token
604- Content-Type: application/json
605- apiKey: anon.api.key
606-
607- {
608- " messages " : [
609- {
610- " event " : " test " ,
611- " payload " : {
612- " value " : 42
613- },
614- " private " : false,
615- " topic " : " realtime:public:messages "
616- }
617- ]
618- }
619- """
620- }
621- }
622-
623579 func testSetAuth( ) async {
624580 let validToken =
625581 " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjY0MDkyMjExMjAwfQ.GfiEKLl36X8YWcatHg31jRbilovlGecfUKnOyXMSX9c "
@@ -683,3 +639,21 @@ extension WebSocketEvent {
683639 return try ? JSONDecoder ( ) . decode ( RealtimeMessageV2 . self, from: Data ( text. utf8) )
684640 }
685641}
642+
643+ struct NoopIssueReporter : IssueReporter {
644+ func reportIssue(
645+ _ message: @autoclosure ( ) -> String ? ,
646+ fileID: StaticString ,
647+ filePath: StaticString ,
648+ line: UInt ,
649+ column: UInt
650+ ) {
651+
652+ }
653+ }
654+
655+ extension IssueReporter where Self == NoopIssueReporter {
656+ static var noop : Self {
657+ Self ( )
658+ }
659+ }
0 commit comments