Skip to content

Commit 45a85f2

Browse files
committed
add tests
1 parent e041784 commit 45a85f2

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed
Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
import Testing
22
@testable import FunctionCalling_MacPaw_OpenAI
3+
import FunctionCalling
34

4-
@Test func example() async throws {
5-
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
5+
actor MacPawOpenAITests {
6+
@FunctionCalling(service: .claude)
7+
struct FunctionContainer {
8+
/// Return current weather of location that passed by the argument
9+
/// - Parameter location: location that
10+
/// - Returns: string of weather
11+
@CallableFunction
12+
func getWeather(location: String) -> String {
13+
return "Sunny"
14+
}
15+
16+
@CallableFunction
17+
func getStock(args: String) -> Int {
18+
return 0
19+
}
20+
}
21+
22+
@Test func checkConvertedResults() async throws {
23+
let functions = FunctionContainer().macPawOpenAITools
24+
25+
#expect(functions.count == 2)
26+
27+
let getWeather = try #require(functions.first?.function)
28+
#expect(getWeather.name == "getWeather")
29+
#expect(getWeather.description == """
30+
Return current weather of location that passed by the argument- Parameter location: location that- Returns: string of weather
31+
""")
32+
33+
let getStock = try #require(functions[1].function)
34+
#expect(getStock.name == "getStock")
35+
#expect(getStock.description == "")
36+
}
637
}

0 commit comments

Comments
 (0)