Skip to content

Commit 45abd97

Browse files
committed
fix: remove ambiguous invoke method
1 parent ac2ed30 commit 45abd97

File tree

2 files changed

+1
-94
lines changed

2 files changed

+1
-94
lines changed

Sources/Functions/FunctionsClient.swift

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public final class FunctionsClient: Sendable {
151151
/// - functionName: The name of the function to invoke.
152152
/// - options: Options for invoking the function. (Default: empty `FunctionInvokeOptions`)
153153
/// - Returns: The raw response and body.
154+
@discardableResult
154155
public func invoke(
155156
_ functionName: String,
156157
options: FunctionInvokeOptions = .init()
@@ -221,18 +222,6 @@ public final class FunctionsClient: Sendable {
221222
}
222223
}
223224

224-
/// Invokes a function without expecting a response.
225-
///
226-
/// - Parameters:
227-
/// - functionName: The name of the function to invoke.
228-
/// - options: Options for invoking the function. (Default: empty `FunctionInvokeOptions`)
229-
public func invoke(
230-
_ functionName: String,
231-
options: FunctionInvokeOptions = .init()
232-
) async throws {
233-
try await invoke(functionName, options: options) { (_, _: HTTPBody) in () }
234-
}
235-
236225
private func _invoke(
237226
functionName: String,
238227
invokeOptions: FunctionInvokeOptions

Tests/FunctionsTests/FunctionsClientTests.swift

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -316,86 +316,4 @@ final class FunctionsClientTests: XCTestCase {
316316
sut.setAuth(token: nil)
317317
XCTAssertNil(sut.headers[.authorization])
318318
}
319-
320-
func testInvokeWithStreamedResponse() async throws {
321-
Mock(
322-
url: url.appendingPathComponent("stream"),
323-
statusCode: 200,
324-
data: [.post: Data("hello world".utf8)]
325-
)
326-
.snapshotRequest {
327-
#"""
328-
curl \
329-
--request POST \
330-
--header "X-Client-Info: functions-swift/0.0.0" \
331-
--header "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" \
332-
"http://localhost:5432/functions/v1/stream"
333-
"""#
334-
}
335-
.register()
336-
337-
let stream = sut._invokeWithStreamedResponse("stream")
338-
339-
for try await value in stream {
340-
XCTAssertEqual(String(decoding: value, as: UTF8.self), "hello world")
341-
}
342-
}
343-
344-
func testInvokeWithStreamedResponseHTTPError() async throws {
345-
Mock(
346-
url: url.appendingPathComponent("stream"),
347-
statusCode: 300,
348-
data: [.post: Data()]
349-
)
350-
.snapshotRequest {
351-
#"""
352-
curl \
353-
--request POST \
354-
--header "X-Client-Info: functions-swift/0.0.0" \
355-
--header "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" \
356-
"http://localhost:5432/functions/v1/stream"
357-
"""#
358-
}
359-
.register()
360-
361-
let stream = sut._invokeWithStreamedResponse("stream")
362-
363-
do {
364-
for try await _ in stream {
365-
XCTFail("should throw error")
366-
}
367-
} catch let FunctionsError.httpError(code, _) {
368-
XCTAssertEqual(code, 300)
369-
}
370-
}
371-
372-
func testInvokeWithStreamedResponseRelayError() async throws {
373-
Mock(
374-
url: url.appendingPathComponent("stream"),
375-
statusCode: 200,
376-
data: [.post: Data()],
377-
additionalHeaders: [
378-
"x-relay-error": "true"
379-
]
380-
)
381-
.snapshotRequest {
382-
#"""
383-
curl \
384-
--request POST \
385-
--header "X-Client-Info: functions-swift/0.0.0" \
386-
--header "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" \
387-
"http://localhost:5432/functions/v1/stream"
388-
"""#
389-
}
390-
.register()
391-
392-
let stream = sut._invokeWithStreamedResponse("stream")
393-
394-
do {
395-
for try await _ in stream {
396-
XCTFail("should throw error")
397-
}
398-
} catch FunctionsError.relayError {
399-
}
400-
}
401319
}

0 commit comments

Comments
 (0)