Post request for refined searches

This commit is contained in:
cdricms
2024-01-14 19:12:03 +01:00
parent b73b9dcd29
commit ee8b791983
3 changed files with 37 additions and 18 deletions

View File

@@ -49,11 +49,23 @@ final class USDATests: XCTestCase {
}
}
func testFoodSearch() async throws {
func testGetFoodSearch() async throws {
let fdc = USDA_FDC_Client()
fdc.apiKey = env["API_KEY"] ?? ""
do {
let _ = try await fdc.getFoodsSearch(.init(query: "cheddar cheese"))
let _ = try await fdc.searchFoods(.init(query: "cheddar cheese"))
} catch {
throw error
}
}
func testPostFoodSearch() async throws {
let fdc = USDA_FDC_Client()
fdc.apiKey = env["API_KEY"] ?? ""
do {
let res = try await fdc.searchFoods(.init(query: "037600106214", dataType: [.Branded]), httpMethod: .POST)
print(res)
} catch {
throw error
}