Skip to content

Commit

Permalink
fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed May 8, 2024
1 parent 8337e36 commit a3e04b0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Sources/Auth/Internal/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct APIClient: Sendable {
throw postgrestError
}

throw HTTPError(data: response.data, response: response.response)
throw HTTPError(data: response.data, response: response.underlyingResponse)
}

return response
Expand Down
10 changes: 0 additions & 10 deletions Sources/Functions/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,6 @@ public struct FunctionInvokeOptions: Sendable {
case put = "PUT"
case patch = "PATCH"
case delete = "DELETE"

var httpMethod: Request.Method {
switch self {
case .get: .get
case .post: .post
case .put: .put
case .patch: .patch
case .delete: .delete
}
}
}

var httpMethod: HTTPMethod? {
Expand Down
2 changes: 1 addition & 1 deletion Sources/PostgREST/PostgrestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public class PostgrestBuilder: @unchecked Sendable {
throw error
}

throw HTTPError(data: response.data, response: response.response)
throw HTTPError(data: response.data, response: response.underlyingResponse)
}

let value = try decode(response.data)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Storage/StorageApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class StorageApi: @unchecked Sendable {
throw error
}

throw HTTPError(data: response.data, response: response.response)
throw HTTPError(data: response.data, response: response.underlyingResponse)
}

return response
Expand Down
16 changes: 16 additions & 0 deletions Tests/FunctionsTests/FunctionsClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ final class FunctionsClientTests: XCTestCase {
XCTAssertEqual(request?.headers["X-Client-Info"], "functions-swift/\(Functions.version)")
}

func testInvokeWithCustomMethod() async throws {
let http = HTTPClientMock().any { _ in try .stub(body: Empty()) }

let sut = FunctionsClient(
url: self.url,
headers: ["Apikey": apiKey],
region: nil,
http: http
)

try await sut.invoke("hello-world", options: .init(method: .delete))

let request = http.receivedRequests.last
XCTAssertEqual(request?.method, .delete)
}

func testInvokeWithRegionDefinedInClient() async throws {
let http = HTTPClientMock()
.any { _ in try .stub(body: Empty()) }
Expand Down

0 comments on commit a3e04b0

Please sign in to comment.