• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-swift / 12913384967

22 Jan 2025 05:08PM UTC coverage: 69.815% (+21.5%) from 48.322%
12913384967

Pull #645

github

web-flow
Merge 82784a670 into 37a32aef8
Pull Request #645: test: integration tests revamp

95 of 134 new or added lines in 16 files covered. (70.9%)

37 existing lines in 8 files now uncovered.

4679 of 6702 relevant lines covered (69.81%)

13.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.65
/Sources/Helpers/HTTP/HTTPClient.swift
1
//
2
//  HTTPClient.swift
3
//
4
//
5
//  Created by Guilherme Souza on 30/04/24.
6
//
7

8
import Foundation
9

10
#if canImport(FoundationNetworking)
11
  import FoundationNetworking
12
#endif
13

14
package protocol HTTPClientType: Sendable {
15
  func send(_ request: HTTPRequest) async throws -> HTTPResponse
16
}
17

18
package actor HTTPClient: HTTPClientType {
19
  let fetch: @Sendable (URLRequest) async throws -> (Data, URLResponse)
20
  let interceptors: [any HTTPClientInterceptor]
21

22
  package init(
23
    fetch: @escaping @Sendable (URLRequest) async throws -> (Data, URLResponse),
24
    interceptors: [any HTTPClientInterceptor]
25
  ) {
214✔
26
    self.fetch = fetch
214✔
27
    self.interceptors = interceptors
214✔
28
  }
214✔
29

30
  package func send(_ request: HTTPRequest) async throws -> HTTPResponse {
122✔
31
    var next: @Sendable (HTTPRequest) async throws -> HTTPResponse = { _request in
122✔
32
      let urlRequest = _request.urlRequest
122✔
33
      let (data, response) = try await self.fetch(urlRequest)
122✔
34
      guard let httpURLResponse = response as? HTTPURLResponse else {
121✔
UNCOV
35
        throw URLError(.badServerResponse)
×
36
      }
121✔
37
      return HTTPResponse(data: data, response: httpURLResponse)
121✔
38
    }
122✔
39

122✔
40
    for interceptor in interceptors.reversed() {
122✔
41
      let tmp = next
41✔
42
      next = {
41✔
43
        try await interceptor.intercept($0, next: tmp)
41✔
44
      }
41✔
45
    }
122✔
46

122✔
47
    return try await next(request)
122✔
48
  }
122✔
49
}
50

51
package protocol HTTPClientInterceptor: Sendable {
52
  func intercept(
53
    _ request: HTTPRequest,
54
    next: @Sendable (HTTPRequest) async throws -> HTTPResponse
55
  ) async throws -> HTTPResponse
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc