Skip to content

Commit f2d05d6

Browse files
authored
Update the vertex golden file version being pulled (#6651)
We've updated from version 3.* to 5.*. Test were added were necessary to match the coverage in the iOS repo. A few changes (v5.1 and v5.2) don't have tests covering the new files yet
1 parent 65b23aa commit f2d05d6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

firebase-vertexai/src/test/java/com/google/firebase/vertexai/UnarySnapshotTests.kt

+12
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import com.google.firebase.vertexai.type.UnsupportedUserLocationException
3333
import com.google.firebase.vertexai.util.goldenUnaryFile
3434
import com.google.firebase.vertexai.util.shouldNotBeNullOrEmpty
3535
import io.kotest.assertions.throwables.shouldThrow
36+
import io.kotest.inspectors.forAtLeastOne
37+
import io.kotest.matchers.collections.shouldContain
3638
import io.kotest.matchers.collections.shouldNotBeEmpty
3739
import io.kotest.matchers.nulls.shouldNotBeNull
3840
import io.kotest.matchers.should
@@ -42,6 +44,7 @@ import io.kotest.matchers.string.shouldContain
4244
import io.kotest.matchers.string.shouldNotBeEmpty
4345
import io.kotest.matchers.types.shouldBeInstanceOf
4446
import io.ktor.http.HttpStatusCode
47+
import java.util.Calendar
4548
import kotlin.time.Duration.Companion.seconds
4649
import kotlinx.coroutines.withTimeout
4750
import kotlinx.serialization.json.JsonPrimitive
@@ -213,6 +216,11 @@ internal class UnarySnapshotTests {
213216
withTimeout(testTimeout) {
214217
val exception = shouldThrow<ResponseStoppedException> { model.generateContent("prompt") }
215218
exception.response.candidates.first().finishReason shouldBe FinishReason.SAFETY
219+
exception.response.candidates.first().safetyRatings.forAtLeastOne {
220+
it.category shouldBe HarmCategory.HARASSMENT
221+
it.probability shouldBe HarmProbability.LOW
222+
it.severity shouldBe HarmSeverity.LOW
223+
}
216224
}
217225
}
218226

@@ -233,6 +241,10 @@ internal class UnarySnapshotTests {
233241

234242
response.candidates.isEmpty() shouldBe false
235243
response.candidates.first().citationMetadata?.citations?.size shouldBe 3
244+
response.candidates.first().citationMetadata?.citations?.forAtLeastOne {
245+
it.publicationDate?.get(Calendar.YEAR) shouldBe 2019
246+
it.publicationDate?.get(Calendar.DAY_OF_MONTH) shouldBe 10
247+
}
236248
}
237249
}
238250

firebase-vertexai/update_responses.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# This script replaces mock response files for Vertex AI unit tests with a fresh
1818
# clone of the shared repository of Vertex AI test data.
1919

20-
RESPONSES_VERSION='v3.*' # The major version of mock responses to use
20+
RESPONSES_VERSION='v5.*' # The major version of mock responses to use
2121
REPO_NAME="vertexai-sdk-test-data"
2222
REPO_LINK="https://github.com/FirebaseExtended/$REPO_NAME.git"
2323

0 commit comments

Comments
 (0)