Skip to content

Commit 9f6cacb

Browse files
andrewheardgoogle-labs-jules[bot]rlazodaymxnmrober
authored
[Vertex AI] Remove golden-files directory (#6740)
Remove the `firebase-vertexai/src/test/resources/golden-files` directory. This was carried over from the [`generative-ai-android`](https://github.com/google-gemini/generative-ai-android) repository. We are now using https://github.com/FirebaseExtended/vertexai-sdk-test-data/tree/main/mock-responses instead. #no-changelog --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Rodrigo Lazo <[email protected]> Co-authored-by: Daymon <[email protected]> Co-authored-by: Matthew Robertson <[email protected]> Co-authored-by: Rodrigo Lazo Paz <[email protected]>
1 parent d0fd4ca commit 9f6cacb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+7
-1200
lines changed

firebase-vertexai/src/test/java/com/google/firebase/vertexai/common/StreamingSnapshotTests.kt

+1-15
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ internal class StreamingSnapshotTests {
6969

7070
@Test
7171
fun `unknown enum`() =
72-
goldenStreamingFile("success-unknown-enum.txt") {
72+
goldenStreamingFile("success-unknown-safety-enum.txt") {
7373
val responses = apiController.generateContentStream(textGenerateContentRequest("prompt"))
7474

7575
withTimeout(testTimeout) {
@@ -152,20 +152,6 @@ internal class StreamingSnapshotTests {
152152
}
153153
}
154154

155-
@Test
156-
fun `citation returns correctly when using alternative name`() =
157-
goldenStreamingFile("success-citations-altname.txt") {
158-
val responses = apiController.generateContentStream(textGenerateContentRequest("prompt"))
159-
160-
withTimeout(testTimeout) {
161-
val responseList = responses.toList()
162-
responseList.any {
163-
it.candidates?.any { it.citationMetadata?.citationSources?.isNotEmpty() ?: false }
164-
?: false
165-
} shouldBe true
166-
}
167-
}
168-
169155
@Test
170156
fun `stopped for recitation`() =
171157
goldenStreamingFile("failure-recitation-no-content.txt") {

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

+2-13
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ internal class UnarySnapshotTests {
7575

7676
@Test
7777
fun `unknown enum`() =
78-
goldenUnaryFile("success-unknown-enum.json") {
78+
goldenUnaryFile("success-unknown-enum-safety-ratings.json") {
7979
withTimeout(testTimeout) {
8080
val response = apiController.generateContent(textGenerateContentRequest("prompt"))
8181

@@ -211,17 +211,6 @@ internal class UnarySnapshotTests {
211211
}
212212
}
213213

214-
@Test
215-
fun `citation returns correctly when using alternative name`() =
216-
goldenUnaryFile("success-citations-altname.json") {
217-
withTimeout(testTimeout) {
218-
val response = apiController.generateContent(textGenerateContentRequest("prompt"))
219-
220-
response.candidates?.isEmpty() shouldBe false
221-
response.candidates?.first()?.citationMetadata?.citationSources?.isNotEmpty() shouldBe true
222-
}
223-
}
224-
225214
@OptIn(ExperimentalSerializationApi::class)
226215
@Test
227216
fun `properly translates json text`() =
@@ -306,7 +295,7 @@ internal class UnarySnapshotTests {
306295

307296
@Test
308297
fun `service disabled`() =
309-
goldenUnaryFile("failure-service-disabled.json", HttpStatusCode.Forbidden) {
298+
goldenUnaryFile("failure-firebaseml-api-not-enabled.json", HttpStatusCode.Forbidden) {
310299
withTimeout(testTimeout) {
311300
shouldThrow<ServiceDisabledException> {
312301
apiController.generateContent(textGenerateContentRequest("prompt"))

firebase-vertexai/src/test/java/com/google/firebase/vertexai/common/util/tests.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ internal fun goldenStreamingFile(
140140
httpStatusCode: HttpStatusCode = HttpStatusCode.OK,
141141
block: CommonTest,
142142
) = doBlocking {
143-
val goldenFile = loadGoldenFile("streaming/$name")
143+
val goldenFile = loadGoldenFile("streaming-$name")
144144
val messages = goldenFile.readLines().filter { it.isNotBlank() }
145145

146146
commonTest(httpStatusCode) {
@@ -171,7 +171,7 @@ internal fun goldenUnaryFile(
171171
block: CommonTest,
172172
) =
173173
commonTest(httpStatusCode) {
174-
val goldenFile = loadGoldenFile("unary/$name")
174+
val goldenFile = loadGoldenFile("unary-$name")
175175
val message = goldenFile.readText()
176176

177177
channel.send(message.toByteArray())
@@ -186,7 +186,8 @@ internal fun goldenUnaryFile(
186186
*
187187
* @see goldenUnaryFile
188188
*/
189-
internal fun loadGoldenFile(path: String): File = loadResourceFile("golden-files/$path")
189+
internal fun loadGoldenFile(path: String): File =
190+
loadResourceFile("vertexai-sdk-test-data/mock-responses/$path")
190191

191192
/** Loads a file from the test resources directory. */
192193
internal fun loadResourceFile(path: String) = File("src/test/resources/$path")

firebase-vertexai/src/test/resources/golden-files/streaming/failure-api-key.txt

-21
This file was deleted.

firebase-vertexai/src/test/resources/golden-files/streaming/failure-empty-content.txt

-1
This file was deleted.

firebase-vertexai/src/test/resources/golden-files/streaming/failure-finish-reason-safety.txt

-2
This file was deleted.

firebase-vertexai/src/test/resources/golden-files/streaming/failure-http-error.txt

-13
This file was deleted.

firebase-vertexai/src/test/resources/golden-files/streaming/failure-image-rejected.txt

-7
This file was deleted.

firebase-vertexai/src/test/resources/golden-files/streaming/failure-prompt-blocked-safety.txt

-2
This file was deleted.

firebase-vertexai/src/test/resources/golden-files/streaming/failure-recitation-no-content.txt

-6
This file was deleted.

firebase-vertexai/src/test/resources/golden-files/streaming/failure-unknown-model.txt

-13
This file was deleted.

firebase-vertexai/src/test/resources/golden-files/streaming/success-basic-reply-long.txt

-12
This file was deleted.

firebase-vertexai/src/test/resources/golden-files/streaming/success-basic-reply-short.txt

-2
This file was deleted.

firebase-vertexai/src/test/resources/golden-files/streaming/success-citations-altname.txt

-12
This file was deleted.

0 commit comments

Comments
 (0)