Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal class StreamingSnapshotTests {

@Test
fun `unknown enum`() =
goldenStreamingFile("success-unknown-enum.txt") {
goldenStreamingFile("success-unknown-safety-enum.txt") {
val responses = apiController.generateContentStream(textGenerateContentRequest("prompt"))

withTimeout(testTimeout) {
Expand Down Expand Up @@ -152,20 +152,6 @@ internal class StreamingSnapshotTests {
}
}

@Test
fun `citation returns correctly when using alternative name`() =
goldenStreamingFile("success-citations-altname.txt") {
val responses = apiController.generateContentStream(textGenerateContentRequest("prompt"))

withTimeout(testTimeout) {
val responseList = responses.toList()
responseList.any {
it.candidates?.any { it.citationMetadata?.citationSources?.isNotEmpty() ?: false }
?: false
} shouldBe true
}
}

@Test
fun `stopped for recitation`() =
goldenStreamingFile("failure-recitation-no-content.txt") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ internal class UnarySnapshotTests {

@Test
fun `unknown enum`() =
goldenUnaryFile("success-unknown-enum.json") {
goldenUnaryFile("success-unknown-enum-safety-ratings.json") {
withTimeout(testTimeout) {
val response = apiController.generateContent(textGenerateContentRequest("prompt"))

Expand Down Expand Up @@ -211,17 +211,6 @@ internal class UnarySnapshotTests {
}
}

@Test
fun `citation returns correctly when using alternative name`() =
goldenUnaryFile("success-citations-altname.json") {
withTimeout(testTimeout) {
val response = apiController.generateContent(textGenerateContentRequest("prompt"))

response.candidates?.isEmpty() shouldBe false
response.candidates?.first()?.citationMetadata?.citationSources?.isNotEmpty() shouldBe true
}
}

@OptIn(ExperimentalSerializationApi::class)
@Test
fun `properly translates json text`() =
Expand Down Expand Up @@ -306,7 +295,7 @@ internal class UnarySnapshotTests {

@Test
fun `service disabled`() =
goldenUnaryFile("failure-service-disabled.json", HttpStatusCode.Forbidden) {
goldenUnaryFile("failure-firebaseml-api-not-enabled.json", HttpStatusCode.Forbidden) {
withTimeout(testTimeout) {
shouldThrow<ServiceDisabledException> {
apiController.generateContent(textGenerateContentRequest("prompt"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ internal fun goldenStreamingFile(
httpStatusCode: HttpStatusCode = HttpStatusCode.OK,
block: CommonTest,
) = doBlocking {
val goldenFile = loadGoldenFile("streaming/$name")
val goldenFile = loadGoldenFile("streaming-$name")
val messages = goldenFile.readLines().filter { it.isNotBlank() }

commonTest(httpStatusCode) {
Expand Down Expand Up @@ -171,7 +171,7 @@ internal fun goldenUnaryFile(
block: CommonTest,
) =
commonTest(httpStatusCode) {
val goldenFile = loadGoldenFile("unary/$name")
val goldenFile = loadGoldenFile("unary-$name")
val message = goldenFile.readText()

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

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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading