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

supabase / supabase-swift / 12907216668

22 Jan 2025 11:27AM UTC coverage: 69.209% (+20.9%) from 48.322%
12907216668

Pull #645

github

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

91 of 117 new or added lines in 13 files covered. (77.78%)

2 existing lines in 2 files now uncovered.

4637 of 6700 relevant lines covered (69.21%)

13.49 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
  ) {
219✔
26
    self.fetch = fetch
219✔
27
    self.interceptors = interceptors
219✔
28
  }
219✔
29

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

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

127✔
47
    return try await next(request)
127✔
48
  }
127✔
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