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

supabase / supabase-swift / 13006424018

28 Jan 2025 08:30AM UTC coverage: 55.865% (+3.4%) from 52.465%
13006424018

Pull #651

github

web-flow
Merge 115194bdb into faf78f673
Pull Request #651: test(postgrest): increase code coverage

35 of 55 new or added lines in 5 files covered. (63.64%)

2 existing lines in 1 file now uncovered.

4734 of 8474 relevant lines covered (55.86%)

14.72 hits per line

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

95.12
/Sources/Helpers/HTTP/HTTPFields.swift
1
import HTTPTypes
2

3
extension HTTPFields {
4
  package init(_ dictionary: [String: String]) {
351✔
5
    self.init(dictionary.map { .init(name: .init($0.key)!, value: $0.value) })
376✔
6
  }
351✔
7

8
  package var dictionary: [String: String] {
13✔
9
    let keyValues = self.map {
46✔
10
      ($0.name.rawName, $0.value)
46✔
11
    }
46✔
12

13✔
13
    return .init(keyValues, uniquingKeysWith: { $1 })
13✔
14
  }
13✔
15

16
  package mutating func merge(with other: Self) {
2✔
17
    for field in other {
7✔
18
      self[field.name] = field.value
7✔
19
    }
7✔
20
  }
2✔
21

22
  package func merging(with other: Self) -> Self {
112✔
23
    var copy = self
112✔
24

112✔
25
    for field in other {
112✔
26
      copy[field.name] = field.value
53✔
27
    }
112✔
28

112✔
29
    return copy
112✔
30
  }
112✔
31

32
  /// Append or update a value in header.
33
  ///
34
  /// Example:
35
  /// ```swift
36
  /// var headers: HTTPFields = [
37
  ///   "Prefer": "count=exact,return=representation"
38
  /// ]
39
  ///
40
  /// headers.appendOrUpdate(.prefer, value: "return=minimal")
41
  /// #expect(headers == ["Prefer": "count=exact,return=minimal"]
42
  /// ```
43
  package mutating func appendOrUpdate(
44
    _ name: HTTPField.Name,
45
    value: String,
46
    separator: String = ","
47
  ) {
4✔
48
    if let currentValue = self[name] {
4✔
49
      var components = currentValue.components(separatedBy: separator)
2✔
50

2✔
51
      if let key = value.split(separator: "=").first,
2✔
52
        let index = components.firstIndex(where: { $0.hasPrefix("\(key)=") })
3✔
53
      {
2✔
54
        components[index] = value
2✔
55
      } else {
2✔
NEW
UNCOV
56
        components.append(value)
×
NEW
UNCOV
57
      }
×
58

2✔
59
      self[name] = components.joined(separator: separator)
2✔
60
    } else {
2✔
61
      self[name] = value
2✔
62
    }
2✔
63
  }
4✔
64
}
65

66
extension HTTPField.Name {
67
  package static let xClientInfo = HTTPField.Name("X-Client-Info")!
68
  package static let xRegion = HTTPField.Name("x-region")!
69
  package static let xRelayError = HTTPField.Name("x-relay-error")!
70
}
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