Skip to content

Commit a0d7bbb

Browse files
committed
Add support for watchOS
1 parent ce3c347 commit a0d7bbb

File tree

4 files changed

+66
-56
lines changed

4 files changed

+66
-56
lines changed

Package.resolved

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"repositoryURL": "https://github.com/Flight-School/AnyCodable",
77
"state": {
88
"branch": null,
9-
"revision": "b1a7a8a6186f2fcb28f7bda67cfc545de48b3c80",
10-
"version": "0.6.2"
9+
"revision": "f9fda69a7b704d46fb5123005f2f7e43dbb8a0fa",
10+
"version": "0.6.5"
1111
}
1212
},
1313
{

Package.swift

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ let package = Package(
99
.iOS(.v11),
1010
.macOS(.v10_10),
1111
.tvOS(.v10),
12+
.watchOS(.v3),
1213
],
1314
products: [
1415
.library(
@@ -30,7 +31,14 @@ let package = Package(
3031
),
3132
.testTarget(
3233
name: "PostgRESTTests",
33-
dependencies: ["PostgREST", "SnapshotTesting"],
34+
dependencies: [
35+
"PostgREST",
36+
.product(
37+
name: "SnapshotTesting",
38+
package: "SnapshotTesting",
39+
condition: .when(platforms: [.iOS, .macOS, .tvOS])
40+
),
41+
],
3442
exclude: [
3543
"__Snapshots__"
3644
]

Sources/PostgREST/Concurrency.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22

33
#if compiler(>=5.5) && canImport(_Concurrency)
4-
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
4+
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
55
extension PostgrestBuilder {
66
@discardableResult
77
public func execute(head: Bool = false, count: CountOption? = nil) async throws
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,61 @@
1-
import Foundation
2-
import SnapshotTesting
3-
import XCTest
1+
#if !os(watchOS)
2+
import Foundation
3+
import SnapshotTesting
4+
import XCTest
45

5-
@testable import PostgREST
6+
@testable import PostgREST
67

7-
#if canImport(FoundationNetworking)
8-
import FoundationNetworking
9-
#endif
8+
#if canImport(FoundationNetworking)
9+
import FoundationNetworking
10+
#endif
1011

11-
final class BuildURLRequestTests: XCTestCase {
12-
let url = "https://example.supabase.co"
12+
final class BuildURLRequestTests: XCTestCase {
13+
let url = "https://example.supabase.co"
1314

14-
struct TestCase {
15-
let name: String
16-
var record = false
17-
let build: (PostgrestClient) throws -> URLRequest
18-
}
15+
struct TestCase {
16+
let name: String
17+
var record = false
18+
let build: (PostgrestClient) throws -> URLRequest
19+
}
1920

20-
func testBuildURLRequest() throws {
21-
let client = PostgrestClient(url: url, schema: nil)
22-
23-
let testCases: [TestCase] = [
24-
TestCase(name: "select all users where email ends with '@supabase.co'") { client in
25-
try client.from("users")
26-
.select()
27-
.like(column: "email", value: "%@supabase.co")
28-
.buildURLRequest(head: false, count: nil)
29-
},
30-
TestCase(name: "insert new user") { client in
31-
try client.from("users")
32-
.insert(values: ["email": "[email protected]"])
33-
.buildURLRequest(head: false, count: nil)
34-
},
35-
TestCase(name: "call rpc") { client in
36-
try client.rpc(fn: "test_fcn", parameters: ["KEY": "VALUE"])
37-
.buildURLRequest(head: false, count: nil)
38-
},
39-
TestCase(name: "call rpc without parameter") { client in
40-
try client.rpc(fn: "test_fcn")
41-
.buildURLRequest(head: false, count: nil)
42-
},
43-
TestCase(name: "test all filters and count") { client in
44-
var query = client.from("todos").select()
45-
46-
for op in PostgrestFilterBuilder.Operator.allCases {
47-
query = query.filter(column: "column", operator: op, value: "Some value")
48-
}
49-
50-
return try query.buildURLRequest(head: false, count: .exact)
51-
},
52-
]
53-
54-
for testCase in testCases {
55-
let request = try testCase.build(client)
56-
assertSnapshot(matching: request, as: .curl, named: testCase.name, record: testCase.record)
21+
func testBuildURLRequest() throws {
22+
let client = PostgrestClient(url: url, schema: nil)
23+
24+
let testCases: [TestCase] = [
25+
TestCase(name: "select all users where email ends with '@supabase.co'") { client in
26+
try client.from("users")
27+
.select()
28+
.like(column: "email", value: "%@supabase.co")
29+
.buildURLRequest(head: false, count: nil)
30+
},
31+
TestCase(name: "insert new user") { client in
32+
try client.from("users")
33+
.insert(values: ["email": "[email protected]"])
34+
.buildURLRequest(head: false, count: nil)
35+
},
36+
TestCase(name: "call rpc") { client in
37+
try client.rpc(fn: "test_fcn", parameters: ["KEY": "VALUE"])
38+
.buildURLRequest(head: false, count: nil)
39+
},
40+
TestCase(name: "call rpc without parameter") { client in
41+
try client.rpc(fn: "test_fcn")
42+
.buildURLRequest(head: false, count: nil)
43+
},
44+
TestCase(name: "test all filters and count") { client in
45+
var query = client.from("todos").select()
46+
47+
for op in PostgrestFilterBuilder.Operator.allCases {
48+
query = query.filter(column: "column", operator: op, value: "Some value")
49+
}
50+
51+
return try query.buildURLRequest(head: false, count: .exact)
52+
},
53+
]
54+
55+
for testCase in testCases {
56+
let request = try testCase.build(client)
57+
assertSnapshot(matching: request, as: .curl, named: testCase.name, record: testCase.record)
58+
}
5759
}
5860
}
59-
}
61+
#endif

0 commit comments

Comments
 (0)