Skip to content

Commit fad5c49

Browse files
authored
Add public API tests for GenerateContentResponse (#133)
1 parent 9156ed7 commit fad5c49

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sources/GoogleAI/GenerateContentResponse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public struct GenerateContentResponse {
5151
}
5252

5353
/// Initializer for SwiftUI previews or tests.
54-
public init(candidates: [CandidateResponse], promptFeedback: PromptFeedback?) {
54+
public init(candidates: [CandidateResponse], promptFeedback: PromptFeedback? = nil) {
5555
self.candidates = candidates
5656
self.promptFeedback = promptFeedback
5757
}

Tests/GoogleAITests/GoogleAITests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@ final class GoogleGenerativeAITests: XCTestCase {
149149
_ = genAI.startChat(history: [ModelContent(parts: "abc")])
150150
}
151151

152+
// Public API tests for GenerateContentResponse.
153+
func generateContentResponseAPI() {
154+
let response = GenerateContentResponse(candidates: [])
155+
156+
let _: [CandidateResponse] = response.candidates
157+
let _: PromptFeedback? = response.promptFeedback
158+
159+
// Computed Properties
160+
let _: String? = response.text
161+
let _: [FunctionCall] = response.functionCalls
162+
}
163+
152164
// Result builder alternative
153165

154166
/*

0 commit comments

Comments
 (0)