diff --git a/firebase-vertexai/src/test/java/com/google/firebase/vertexai/StreamingSnapshotTests.kt b/firebase-vertexai/src/test/java/com/google/firebase/vertexai/VertexAIStreamingSnapshotTests.kt similarity index 82% rename from firebase-vertexai/src/test/java/com/google/firebase/vertexai/StreamingSnapshotTests.kt rename to firebase-vertexai/src/test/java/com/google/firebase/vertexai/VertexAIStreamingSnapshotTests.kt index ce53bcf9e33..981144a8e14 100644 --- a/firebase-vertexai/src/test/java/com/google/firebase/vertexai/StreamingSnapshotTests.kt +++ b/firebase-vertexai/src/test/java/com/google/firebase/vertexai/VertexAIStreamingSnapshotTests.kt @@ -25,7 +25,7 @@ import com.google.firebase.vertexai.type.ResponseStoppedException import com.google.firebase.vertexai.type.SerializationException import com.google.firebase.vertexai.type.ServerException import com.google.firebase.vertexai.type.TextPart -import com.google.firebase.vertexai.util.goldenStreamingFile +import com.google.firebase.vertexai.util.goldenVertexStreamingFile import io.kotest.assertions.throwables.shouldThrow import io.kotest.matchers.nulls.shouldNotBeNull import io.kotest.matchers.shouldBe @@ -33,17 +33,16 @@ import io.kotest.matchers.string.shouldContain import io.ktor.http.HttpStatusCode import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.toList import kotlinx.coroutines.withTimeout import org.junit.Test -internal class StreamingSnapshotTests { +internal class VertexAIStreamingSnapshotTests { private val testTimeout = 5.seconds @Test fun `short reply`() = - goldenStreamingFile("streaming-success-basic-reply-short.txt") { + goldenVertexStreamingFile("streaming-success-basic-reply-short.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { @@ -57,7 +56,7 @@ internal class StreamingSnapshotTests { @Test fun `long reply`() = - goldenStreamingFile("streaming-success-basic-reply-long.txt") { + goldenVertexStreamingFile("streaming-success-basic-reply-long.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { @@ -73,7 +72,7 @@ internal class StreamingSnapshotTests { @Test fun `unknown enum in safety ratings`() = - goldenStreamingFile("streaming-success-unknown-safety-enum.txt") { + goldenVertexStreamingFile("streaming-success-unknown-safety-enum.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { @@ -88,7 +87,7 @@ internal class StreamingSnapshotTests { @Test fun `unknown enum in finish reason`() = - goldenStreamingFile("streaming-failure-unknown-finish-enum.txt") { + goldenVertexStreamingFile("streaming-failure-unknown-finish-enum.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { @@ -99,7 +98,7 @@ internal class StreamingSnapshotTests { @Test fun `quotes escaped`() = - goldenStreamingFile("streaming-success-quotes-escaped.txt") { + goldenVertexStreamingFile("streaming-success-quotes-escaped.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { @@ -114,7 +113,7 @@ internal class StreamingSnapshotTests { @Test fun `prompt blocked for safety`() = - goldenStreamingFile("streaming-failure-prompt-blocked-safety.txt") { + goldenVertexStreamingFile("streaming-failure-prompt-blocked-safety.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { @@ -125,7 +124,7 @@ internal class StreamingSnapshotTests { @Test fun `prompt blocked for safety with message`() = - goldenStreamingFile("streaming-failure-prompt-blocked-safety-with-message.txt") { + goldenVertexStreamingFile("streaming-failure-prompt-blocked-safety-with-message.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { @@ -137,7 +136,7 @@ internal class StreamingSnapshotTests { @Test fun `empty content`() = - goldenStreamingFile("streaming-failure-empty-content.txt") { + goldenVertexStreamingFile("streaming-failure-empty-content.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { shouldThrow { responses.collect() } } @@ -145,7 +144,10 @@ internal class StreamingSnapshotTests { @Test fun `http errors`() = - goldenStreamingFile("streaming-failure-http-error.txt", HttpStatusCode.PreconditionFailed) { + goldenVertexStreamingFile( + "streaming-failure-http-error.txt", + HttpStatusCode.PreconditionFailed + ) { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { shouldThrow { responses.collect() } } @@ -153,7 +155,7 @@ internal class StreamingSnapshotTests { @Test fun `stopped for safety`() = - goldenStreamingFile("streaming-failure-finish-reason-safety.txt") { + goldenVertexStreamingFile("streaming-failure-finish-reason-safety.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { @@ -164,7 +166,7 @@ internal class StreamingSnapshotTests { @Test fun `citation parsed correctly`() = - goldenStreamingFile("streaming-success-citations.txt") { + goldenVertexStreamingFile("streaming-success-citations.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { @@ -177,7 +179,7 @@ internal class StreamingSnapshotTests { @Test fun `stopped for recitation`() = - goldenStreamingFile("streaming-failure-recitation-no-content.txt") { + goldenVertexStreamingFile("streaming-failure-recitation-no-content.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { @@ -188,7 +190,7 @@ internal class StreamingSnapshotTests { @Test fun `image rejected`() = - goldenStreamingFile("streaming-failure-image-rejected.txt", HttpStatusCode.BadRequest) { + goldenVertexStreamingFile("streaming-failure-image-rejected.txt", HttpStatusCode.BadRequest) { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { shouldThrow { responses.collect() } } @@ -196,7 +198,7 @@ internal class StreamingSnapshotTests { @Test fun `unknown model`() = - goldenStreamingFile("streaming-failure-unknown-model.txt", HttpStatusCode.NotFound) { + goldenVertexStreamingFile("streaming-failure-unknown-model.txt", HttpStatusCode.NotFound) { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { shouldThrow { responses.collect() } } @@ -204,7 +206,7 @@ internal class StreamingSnapshotTests { @Test fun `invalid api key`() = - goldenStreamingFile("streaming-failure-api-key.txt", HttpStatusCode.BadRequest) { + goldenVertexStreamingFile("streaming-failure-api-key.txt", HttpStatusCode.BadRequest) { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { shouldThrow { responses.collect() } } @@ -212,7 +214,7 @@ internal class StreamingSnapshotTests { @Test fun `invalid json`() = - goldenStreamingFile("streaming-failure-invalid-json.txt") { + goldenVertexStreamingFile("streaming-failure-invalid-json.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { shouldThrow { responses.collect() } } @@ -220,7 +222,7 @@ internal class StreamingSnapshotTests { @Test fun `malformed content`() = - goldenStreamingFile("streaming-failure-malformed-content.txt") { + goldenVertexStreamingFile("streaming-failure-malformed-content.txt") { val responses = model.generateContentStream("prompt") withTimeout(testTimeout) { shouldThrow { responses.collect() } } diff --git a/firebase-vertexai/src/test/java/com/google/firebase/vertexai/UnarySnapshotTests.kt b/firebase-vertexai/src/test/java/com/google/firebase/vertexai/VertexAIUnarySnapshotTests.kt similarity index 84% rename from firebase-vertexai/src/test/java/com/google/firebase/vertexai/UnarySnapshotTests.kt rename to firebase-vertexai/src/test/java/com/google/firebase/vertexai/VertexAIUnarySnapshotTests.kt index a7ed1c4ed7f..f3603814423 100644 --- a/firebase-vertexai/src/test/java/com/google/firebase/vertexai/UnarySnapshotTests.kt +++ b/firebase-vertexai/src/test/java/com/google/firebase/vertexai/VertexAIUnarySnapshotTests.kt @@ -34,7 +34,7 @@ import com.google.firebase.vertexai.type.ServerException import com.google.firebase.vertexai.type.ServiceDisabledException import com.google.firebase.vertexai.type.TextPart import com.google.firebase.vertexai.type.UnsupportedUserLocationException -import com.google.firebase.vertexai.util.goldenUnaryFile +import com.google.firebase.vertexai.util.goldenVertexUnaryFile import com.google.firebase.vertexai.util.shouldNotBeNullOrEmpty import io.kotest.assertions.throwables.shouldThrow import io.kotest.inspectors.forAtLeastOne @@ -57,12 +57,12 @@ import org.json.JSONArray import org.junit.Test @OptIn(PublicPreviewAPI::class) -internal class UnarySnapshotTests { +internal class VertexAIUnarySnapshotTests { private val testTimeout = 5.seconds @Test fun `short reply`() = - goldenUnaryFile("unary-success-basic-reply-short.json") { + goldenVertexUnaryFile("unary-success-basic-reply-short.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") @@ -75,7 +75,7 @@ internal class UnarySnapshotTests { @Test fun `long reply`() = - goldenUnaryFile("unary-success-basic-reply-long.json") { + goldenVertexUnaryFile("unary-success-basic-reply-long.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") @@ -88,7 +88,7 @@ internal class UnarySnapshotTests { @Test fun `response with detailed token-based usageMetadata`() = - goldenUnaryFile("unary-success-basic-response-long-usage-metadata.json") { + goldenVertexUnaryFile("unary-success-basic-response-long-usage-metadata.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") @@ -113,7 +113,7 @@ internal class UnarySnapshotTests { @Test fun `unknown enum in safety ratings`() = - goldenUnaryFile("unary-success-unknown-enum-safety-ratings.json") { + goldenVertexUnaryFile("unary-success-unknown-enum-safety-ratings.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") @@ -127,7 +127,7 @@ internal class UnarySnapshotTests { @Test fun `unknown enum in finish reason`() = - goldenUnaryFile("unary-failure-unknown-enum-finish-reason.json") { + goldenVertexUnaryFile("unary-failure-unknown-enum-finish-reason.json") { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } should { @@ -138,7 +138,7 @@ internal class UnarySnapshotTests { @Test fun `unknown enum in block reason`() = - goldenUnaryFile("unary-failure-unknown-enum-prompt-blocked.json") { + goldenVertexUnaryFile("unary-failure-unknown-enum-prompt-blocked.json") { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } should { @@ -149,7 +149,7 @@ internal class UnarySnapshotTests { @Test fun `quotes escaped`() = - goldenUnaryFile("unary-success-quote-reply.json") { + goldenVertexUnaryFile("unary-success-quote-reply.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") @@ -162,7 +162,7 @@ internal class UnarySnapshotTests { @Test fun `safetyRatings missing`() = - goldenUnaryFile("unary-success-missing-safety-ratings.json") { + goldenVertexUnaryFile("unary-success-missing-safety-ratings.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") @@ -175,7 +175,7 @@ internal class UnarySnapshotTests { @Test fun `safetyRatings including severity`() = - goldenUnaryFile("unary-success-including-severity.json") { + goldenVertexUnaryFile("unary-success-including-severity.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") @@ -193,7 +193,7 @@ internal class UnarySnapshotTests { @Test fun `function call has no arguments field`() = - goldenUnaryFile("unary-success-function-call-empty-arguments.json") { + goldenVertexUnaryFile("unary-success-function-call-empty-arguments.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") val content = response.candidates.shouldNotBeNullOrEmpty().first().content @@ -207,7 +207,7 @@ internal class UnarySnapshotTests { @Test fun `prompt blocked for safety`() = - goldenUnaryFile("unary-failure-prompt-blocked-safety.json") { + goldenVertexUnaryFile("unary-failure-prompt-blocked-safety.json") { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } should { @@ -218,7 +218,7 @@ internal class UnarySnapshotTests { @Test fun `prompt blocked for safety with message`() = - goldenUnaryFile("unary-failure-prompt-blocked-safety-with-message.json") { + goldenVertexUnaryFile("unary-failure-prompt-blocked-safety-with-message.json") { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } should { @@ -230,7 +230,7 @@ internal class UnarySnapshotTests { @Test fun `empty content`() = - goldenUnaryFile("unary-failure-empty-content.json") { + goldenVertexUnaryFile("unary-failure-empty-content.json") { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } } @@ -238,13 +238,13 @@ internal class UnarySnapshotTests { @Test fun `http error`() = - goldenUnaryFile("unary-failure-http-error.json", HttpStatusCode.PreconditionFailed) { + goldenVertexUnaryFile("unary-failure-http-error.json", HttpStatusCode.PreconditionFailed) { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } } } @Test fun `user location error`() = - goldenUnaryFile( + goldenVertexUnaryFile( "unary-failure-unsupported-user-location.json", HttpStatusCode.PreconditionFailed, ) { @@ -255,7 +255,7 @@ internal class UnarySnapshotTests { @Test fun `stopped for safety`() = - goldenUnaryFile("unary-failure-finish-reason-safety.json") { + goldenVertexUnaryFile("unary-failure-finish-reason-safety.json") { withTimeout(testTimeout) { val exception = shouldThrow { model.generateContent("prompt") } exception.response.candidates.first().finishReason shouldBe FinishReason.SAFETY @@ -269,7 +269,7 @@ internal class UnarySnapshotTests { @Test fun `quota exceeded`() = - goldenUnaryFile("unary-failure-quota-exceeded.json", HttpStatusCode.BadRequest) { + goldenVertexUnaryFile("unary-failure-quota-exceeded.json", HttpStatusCode.BadRequest) { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } } @@ -277,7 +277,7 @@ internal class UnarySnapshotTests { @Test fun `stopped for safety with no content`() = - goldenUnaryFile("unary-failure-finish-reason-safety-no-content.json") { + goldenVertexUnaryFile("unary-failure-finish-reason-safety-no-content.json") { withTimeout(testTimeout) { val exception = shouldThrow { model.generateContent("prompt") } exception.response.candidates.first().finishReason shouldBe FinishReason.SAFETY @@ -286,7 +286,7 @@ internal class UnarySnapshotTests { @Test fun `citation returns correctly`() = - goldenUnaryFile("unary-success-citations.json") { + goldenVertexUnaryFile("unary-success-citations.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") @@ -301,7 +301,7 @@ internal class UnarySnapshotTests { @Test fun `citation returns correctly with missing license and startIndex`() = - goldenUnaryFile("unary-success-citations-nolicense.json") { + goldenVertexUnaryFile("unary-success-citations-nolicense.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") @@ -320,7 +320,7 @@ internal class UnarySnapshotTests { @Test fun `response includes usage metadata`() = - goldenUnaryFile("unary-success-usage-metadata.json") { + goldenVertexUnaryFile("unary-success-usage-metadata.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") @@ -334,7 +334,7 @@ internal class UnarySnapshotTests { @Test fun `response includes partial usage metadata`() = - goldenUnaryFile("unary-success-partial-usage-metadata.json") { + goldenVertexUnaryFile("unary-success-partial-usage-metadata.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") @@ -348,7 +348,7 @@ internal class UnarySnapshotTests { @Test fun `properly translates json text`() = - goldenUnaryFile("unary-success-constraint-decoding-json.json") { + goldenVertexUnaryFile("unary-success-constraint-decoding-json.json") { val response = model.generateContent("prompt") response.candidates.isEmpty() shouldBe false @@ -368,7 +368,7 @@ internal class UnarySnapshotTests { @Test fun `invalid response`() = - goldenUnaryFile("unary-failure-invalid-response.json") { + goldenVertexUnaryFile("unary-failure-invalid-response.json") { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } } @@ -376,7 +376,7 @@ internal class UnarySnapshotTests { @Test fun `malformed content`() = - goldenUnaryFile("unary-failure-malformed-content.json") { + goldenVertexUnaryFile("unary-failure-malformed-content.json") { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } } @@ -384,7 +384,7 @@ internal class UnarySnapshotTests { @Test fun `invalid api key`() = - goldenUnaryFile("unary-failure-api-key.json", HttpStatusCode.BadRequest) { + goldenVertexUnaryFile("unary-failure-api-key.json", HttpStatusCode.BadRequest) { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } } @@ -392,19 +392,22 @@ internal class UnarySnapshotTests { @Test fun `image rejected`() = - goldenUnaryFile("unary-failure-image-rejected.json", HttpStatusCode.BadRequest) { + goldenVertexUnaryFile("unary-failure-image-rejected.json", HttpStatusCode.BadRequest) { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } } } @Test fun `unknown model`() = - goldenUnaryFile("unary-failure-unknown-model.json", HttpStatusCode.NotFound) { + goldenVertexUnaryFile("unary-failure-unknown-model.json", HttpStatusCode.NotFound) { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } } } @Test fun `service disabled`() = - goldenUnaryFile("unary-failure-firebaseml-api-not-enabled.json", HttpStatusCode.Forbidden) { + goldenVertexUnaryFile( + "unary-failure-firebaseml-api-not-enabled.json", + HttpStatusCode.Forbidden + ) { withTimeout(testTimeout) { shouldThrow { model.generateContent("prompt") } } @@ -412,7 +415,7 @@ internal class UnarySnapshotTests { @Test fun `function call contains null param`() = - goldenUnaryFile("unary-success-function-call-null.json") { + goldenVertexUnaryFile("unary-success-function-call-null.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") val callPart = (response.candidates.first().content.parts.first() as FunctionCallPart) @@ -423,7 +426,7 @@ internal class UnarySnapshotTests { @Test fun `function call contains json literal`() = - goldenUnaryFile("unary-success-function-call-json-literal.json") { + goldenVertexUnaryFile("unary-success-function-call-json-literal.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") val content = response.candidates.shouldNotBeNullOrEmpty().first().content @@ -440,7 +443,7 @@ internal class UnarySnapshotTests { @Test fun `function call with complex json literal parses correctly`() = - goldenUnaryFile("unary-success-function-call-complex-json-literal.json") { + goldenVertexUnaryFile("unary-success-function-call-complex-json-literal.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") val content = response.candidates.shouldNotBeNullOrEmpty().first().content @@ -459,7 +462,7 @@ internal class UnarySnapshotTests { @Test fun `function call contains no arguments`() = - goldenUnaryFile("unary-success-function-call-no-arguments.json") { + goldenVertexUnaryFile("unary-success-function-call-no-arguments.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") val callPart = response.functionCalls.shouldNotBeEmpty().first() @@ -471,7 +474,7 @@ internal class UnarySnapshotTests { @Test fun `function call contains arguments`() = - goldenUnaryFile("unary-success-function-call-with-arguments.json") { + goldenVertexUnaryFile("unary-success-function-call-with-arguments.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") val callPart = response.functionCalls.shouldNotBeEmpty().first() @@ -484,7 +487,7 @@ internal class UnarySnapshotTests { @Test fun `function call with parallel calls`() = - goldenUnaryFile("unary-success-function-call-parallel-calls.json") { + goldenVertexUnaryFile("unary-success-function-call-parallel-calls.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") val callList = response.functionCalls @@ -499,7 +502,7 @@ internal class UnarySnapshotTests { @Test fun `function call with mixed content`() = - goldenUnaryFile("unary-success-function-call-mixed-content.json") { + goldenVertexUnaryFile("unary-success-function-call-mixed-content.json") { withTimeout(testTimeout) { val response = model.generateContent("prompt") val callList = response.functionCalls @@ -512,7 +515,7 @@ internal class UnarySnapshotTests { @Test fun `countTokens succeeds`() = - goldenUnaryFile("unary-success-total-tokens.json") { + goldenVertexUnaryFile("unary-success-total-tokens.json") { withTimeout(testTimeout) { val response = model.countTokens("prompt") @@ -524,7 +527,7 @@ internal class UnarySnapshotTests { @Test fun `countTokens with modality fields returned`() = - goldenUnaryFile("unary-success-detailed-token-response.json") { + goldenVertexUnaryFile("unary-success-detailed-token-response.json") { withTimeout(testTimeout) { val response = model.countTokens("prompt") @@ -540,7 +543,7 @@ internal class UnarySnapshotTests { @Test fun `countTokens succeeds with no billable characters`() = - goldenUnaryFile("unary-success-no-billable-characters.json") { + goldenVertexUnaryFile("unary-success-no-billable-characters.json") { withTimeout(testTimeout) { val response = model.countTokens("prompt") @@ -551,13 +554,13 @@ internal class UnarySnapshotTests { @Test fun `countTokens fails with model not found`() = - goldenUnaryFile("unary-failure-model-not-found.json", HttpStatusCode.NotFound) { + goldenVertexUnaryFile("unary-failure-model-not-found.json", HttpStatusCode.NotFound) { withTimeout(testTimeout) { shouldThrow { model.countTokens("prompt") } } } @Test fun `generateImages should throw when all images filtered`() = - goldenUnaryFile("unary-failure-generate-images-all-filtered.json") { + goldenVertexUnaryFile("unary-failure-generate-images-all-filtered.json") { withTimeout(testTimeout) { shouldThrow { imagenModel.generateImages("prompt") } } @@ -565,7 +568,7 @@ internal class UnarySnapshotTests { @Test fun `generateImages should throw when prompt blocked`() = - goldenUnaryFile( + goldenVertexUnaryFile( "unary-failure-generate-images-prompt-blocked.json", HttpStatusCode.BadRequest, ) { diff --git a/firebase-vertexai/src/test/java/com/google/firebase/vertexai/util/tests.kt b/firebase-vertexai/src/test/java/com/google/firebase/vertexai/util/tests.kt index 9428aea67ef..4f648735396 100644 --- a/firebase-vertexai/src/test/java/com/google/firebase/vertexai/util/tests.kt +++ b/firebase-vertexai/src/test/java/com/google/firebase/vertexai/util/tests.kt @@ -125,7 +125,7 @@ internal fun commonTest( * @param name The name of the *Golden File* to load * @param httpStatusCode An optional [HttpStatusCode] to return as a response * @param block The test contents themselves, with a [CommonTestScope] implicitly provided - * @see goldenUnaryFile + * @see goldenVertexUnaryFile */ internal fun goldenStreamingFile( name: String, @@ -147,6 +147,23 @@ internal fun goldenStreamingFile( } } +/** + * A variant of [goldenStreamingFile] for testing vertexAI + * + * Loads the *Golden File* and automatically parses the messages from it; providing it to the + * channel. + * + * @param name The name of the *Golden File* to load + * @param httpStatusCode An optional [HttpStatusCode] to return as a response + * @param block The test contents themselves, with a [CommonTestScope] implicitly provided + * @see goldenStreamingFile + */ +internal fun goldenVertexStreamingFile( + name: String, + httpStatusCode: HttpStatusCode = HttpStatusCode.OK, + block: CommonTest, +) = goldenStreamingFile("vertexai/$name", httpStatusCode, block) + /** * A variant of [commonTest] for performing snapshot tests. * @@ -171,6 +188,21 @@ internal fun goldenUnaryFile( block() } +/** + * A variant of [goldenUnaryFile] for vertexai tests Loads the *Golden File* and automatically + * provides it to the channel. + * + * @param name The name of the *Golden File* to load + * @param httpStatusCode An optional [HttpStatusCode] to return as a response + * @param block The test contents themselves, with a [CommonTestScope] implicitly provided + * @see goldenUnaryFile + */ +internal fun goldenVertexUnaryFile( + name: String, + httpStatusCode: HttpStatusCode = HttpStatusCode.OK, + block: CommonTest, +) = goldenUnaryFile("vertexai/$name", httpStatusCode, block) + /** * Loads a *Golden File* from the resource directory. * diff --git a/firebase-vertexai/update_responses.sh b/firebase-vertexai/update_responses.sh index 3feec3b861b..28b0be1a25a 100755 --- a/firebase-vertexai/update_responses.sh +++ b/firebase-vertexai/update_responses.sh @@ -17,7 +17,7 @@ # This script replaces mock response files for Vertex AI unit tests with a fresh # clone of the shared repository of Vertex AI test data. -RESPONSES_VERSION='v6.*' # The major version of mock responses to use +RESPONSES_VERSION='v7.*' # The major version of mock responses to use REPO_NAME="vertexai-sdk-test-data" REPO_LINK="https://github.com/FirebaseExtended/$REPO_NAME.git"