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

supabase / supabase-swift / 12906979978

22 Jan 2025 11:13AM UTC coverage: 54.597% (+6.3%) from 48.322%
12906979978

Pull #645

github

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

14 of 117 new or added lines in 13 files covered. (11.97%)

46 existing lines in 5 files now uncovered.

3658 of 6700 relevant lines covered (54.6%)

11.52 hits per line

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

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

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

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

21✔
13
    return .init(keyValues, uniquingKeysWith: { $1 })
21✔
14
  }
21✔
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 {
74✔
23
    var copy = self
74✔
24

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

74✔
29
    return copy
74✔
30
  }
74✔
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 = ","
NEW
47
  ) {
×
NEW
48
    if let currentValue = self[name] {
×
NEW
49
      var components = currentValue.components(separatedBy: separator)
×
NEW
50

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

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