• 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.12
/Sources/Helpers/HTTP/HTTPFields.swift
1
import HTTPTypes
2

3
extension HTTPFields {
4
  package init(_ dictionary: [String: String]) {
272✔
5
    self.init(dictionary.map { .init(name: .init($0.key)!, value: $0.value) })
282✔
6
  }
272✔
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 {
85✔
23
    var copy = self
85✔
24

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

85✔
29
    return copy
85✔
30
  }
85✔
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
  ) {
2✔
48
    if let currentValue = self[name] {
2✔
49
      var components = currentValue.components(separatedBy: separator)
1✔
50

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

1✔
59
      self[name] = components.joined(separator: separator)
1✔
60
    } else {
1✔
61
      self[name] = value
1✔
62
    }
1✔
63
  }
2✔
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