|
1 |
| -import Foundation |
2 |
| -import SnapshotTesting |
3 |
| -import XCTest |
| 1 | +#if !os(watchOS) |
| 2 | + import Foundation |
| 3 | + import SnapshotTesting |
| 4 | + import XCTest |
4 | 5 |
|
5 |
| -@testable import PostgREST |
| 6 | + @testable import PostgREST |
6 | 7 |
|
7 |
| -#if canImport(FoundationNetworking) |
8 |
| - import FoundationNetworking |
9 |
| -#endif |
| 8 | + #if canImport(FoundationNetworking) |
| 9 | + import FoundationNetworking |
| 10 | + #endif |
10 | 11 |
|
11 |
| -final class BuildURLRequestTests: XCTestCase { |
12 |
| - let url = "https://example.supabase.co" |
| 12 | + final class BuildURLRequestTests: XCTestCase { |
| 13 | + let url = "https://example.supabase.co" |
13 | 14 |
|
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 | + } |
19 | 20 |
|
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 | + } |
57 | 59 | }
|
58 | 60 | }
|
59 |
| -} |
| 61 | +#endif |
0 commit comments