From dea1f7ed83a401315878a27406d8be4813719159 Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Mon, 15 Apr 2024 12:59:20 -0400 Subject: [PATCH] Add public API tests for `GenerateContentResponse` in Vertex AI (#12791) --- .../Tests/Unit/VertexAIAPITests.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/FirebaseVertexAI/Tests/Unit/VertexAIAPITests.swift b/FirebaseVertexAI/Tests/Unit/VertexAIAPITests.swift index e9312edfee0..75fb8946d22 100644 --- a/FirebaseVertexAI/Tests/Unit/VertexAIAPITests.swift +++ b/FirebaseVertexAI/Tests/Unit/VertexAIAPITests.swift @@ -167,6 +167,24 @@ final class VertexAIAPITests: XCTestCase { _ = genAI.startChat(history: [ModelContent(parts: "abc")]) } + // Public API tests for GenerateContentResponse. + func generateContentResponseAPI() { + let response = GenerateContentResponse(candidates: []) + + let _: [CandidateResponse] = response.candidates + let _: PromptFeedback? = response.promptFeedback + + // Usage Metadata + guard let usageMetadata = response.usageMetadata else { fatalError() } + let _: Int = usageMetadata.promptTokenCount + let _: Int = usageMetadata.candidatesTokenCount + let _: Int = usageMetadata.totalTokenCount + + // Computed Properties + let _: String? = response.text + let _: [FunctionCall] = response.functionCalls + } + // Result builder alternative /*