Skip to content

Commit e61db47

Browse files
davidmotsonDavid Motsonashvili
authored andcommitted
fix for new version of golden files (#6771)
Co-authored-by: David Motsonashvili <[email protected]>
1 parent 8b7d3d7 commit e61db47

File tree

4 files changed

+103
-66
lines changed

4 files changed

+103
-66
lines changed

firebase-vertexai/src/test/java/com/google/firebase/vertexai/StreamingSnapshotTests.kt renamed to firebase-vertexai/src/test/java/com/google/firebase/vertexai/VertexAIStreamingSnapshotTests.kt

+22-20
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,24 @@ import com.google.firebase.vertexai.type.ResponseStoppedException
2525
import com.google.firebase.vertexai.type.SerializationException
2626
import com.google.firebase.vertexai.type.ServerException
2727
import com.google.firebase.vertexai.type.TextPart
28-
import com.google.firebase.vertexai.util.goldenStreamingFile
28+
import com.google.firebase.vertexai.util.goldenVertexStreamingFile
2929
import io.kotest.assertions.throwables.shouldThrow
3030
import io.kotest.matchers.nulls.shouldNotBeNull
3131
import io.kotest.matchers.shouldBe
3232
import io.kotest.matchers.string.shouldContain
3333
import io.ktor.http.HttpStatusCode
3434
import kotlin.time.Duration.Companion.seconds
3535
import kotlinx.coroutines.flow.collect
36-
import kotlinx.coroutines.flow.first
3736
import kotlinx.coroutines.flow.toList
3837
import kotlinx.coroutines.withTimeout
3938
import org.junit.Test
4039

41-
internal class StreamingSnapshotTests {
40+
internal class VertexAIStreamingSnapshotTests {
4241
private val testTimeout = 5.seconds
4342

4443
@Test
4544
fun `short reply`() =
46-
goldenStreamingFile("streaming-success-basic-reply-short.txt") {
45+
goldenVertexStreamingFile("streaming-success-basic-reply-short.txt") {
4746
val responses = model.generateContentStream("prompt")
4847

4948
withTimeout(testTimeout) {
@@ -57,7 +56,7 @@ internal class StreamingSnapshotTests {
5756

5857
@Test
5958
fun `long reply`() =
60-
goldenStreamingFile("streaming-success-basic-reply-long.txt") {
59+
goldenVertexStreamingFile("streaming-success-basic-reply-long.txt") {
6160
val responses = model.generateContentStream("prompt")
6261

6362
withTimeout(testTimeout) {
@@ -73,7 +72,7 @@ internal class StreamingSnapshotTests {
7372

7473
@Test
7574
fun `unknown enum in safety ratings`() =
76-
goldenStreamingFile("streaming-success-unknown-safety-enum.txt") {
75+
goldenVertexStreamingFile("streaming-success-unknown-safety-enum.txt") {
7776
val responses = model.generateContentStream("prompt")
7877

7978
withTimeout(testTimeout) {
@@ -88,7 +87,7 @@ internal class StreamingSnapshotTests {
8887

8988
@Test
9089
fun `unknown enum in finish reason`() =
91-
goldenStreamingFile("streaming-failure-unknown-finish-enum.txt") {
90+
goldenVertexStreamingFile("streaming-failure-unknown-finish-enum.txt") {
9291
val responses = model.generateContentStream("prompt")
9392

9493
withTimeout(testTimeout) {
@@ -99,7 +98,7 @@ internal class StreamingSnapshotTests {
9998

10099
@Test
101100
fun `quotes escaped`() =
102-
goldenStreamingFile("streaming-success-quotes-escaped.txt") {
101+
goldenVertexStreamingFile("streaming-success-quotes-escaped.txt") {
103102
val responses = model.generateContentStream("prompt")
104103

105104
withTimeout(testTimeout) {
@@ -114,7 +113,7 @@ internal class StreamingSnapshotTests {
114113

115114
@Test
116115
fun `prompt blocked for safety`() =
117-
goldenStreamingFile("streaming-failure-prompt-blocked-safety.txt") {
116+
goldenVertexStreamingFile("streaming-failure-prompt-blocked-safety.txt") {
118117
val responses = model.generateContentStream("prompt")
119118

120119
withTimeout(testTimeout) {
@@ -125,7 +124,7 @@ internal class StreamingSnapshotTests {
125124

126125
@Test
127126
fun `prompt blocked for safety with message`() =
128-
goldenStreamingFile("streaming-failure-prompt-blocked-safety-with-message.txt") {
127+
goldenVertexStreamingFile("streaming-failure-prompt-blocked-safety-with-message.txt") {
129128
val responses = model.generateContentStream("prompt")
130129

131130
withTimeout(testTimeout) {
@@ -137,23 +136,26 @@ internal class StreamingSnapshotTests {
137136

138137
@Test
139138
fun `empty content`() =
140-
goldenStreamingFile("streaming-failure-empty-content.txt") {
139+
goldenVertexStreamingFile("streaming-failure-empty-content.txt") {
141140
val responses = model.generateContentStream("prompt")
142141

143142
withTimeout(testTimeout) { shouldThrow<SerializationException> { responses.collect() } }
144143
}
145144

146145
@Test
147146
fun `http errors`() =
148-
goldenStreamingFile("streaming-failure-http-error.txt", HttpStatusCode.PreconditionFailed) {
147+
goldenVertexStreamingFile(
148+
"streaming-failure-http-error.txt",
149+
HttpStatusCode.PreconditionFailed
150+
) {
149151
val responses = model.generateContentStream("prompt")
150152

151153
withTimeout(testTimeout) { shouldThrow<ServerException> { responses.collect() } }
152154
}
153155

154156
@Test
155157
fun `stopped for safety`() =
156-
goldenStreamingFile("streaming-failure-finish-reason-safety.txt") {
158+
goldenVertexStreamingFile("streaming-failure-finish-reason-safety.txt") {
157159
val responses = model.generateContentStream("prompt")
158160

159161
withTimeout(testTimeout) {
@@ -164,7 +166,7 @@ internal class StreamingSnapshotTests {
164166

165167
@Test
166168
fun `citation parsed correctly`() =
167-
goldenStreamingFile("streaming-success-citations.txt") {
169+
goldenVertexStreamingFile("streaming-success-citations.txt") {
168170
val responses = model.generateContentStream("prompt")
169171

170172
withTimeout(testTimeout) {
@@ -177,7 +179,7 @@ internal class StreamingSnapshotTests {
177179

178180
@Test
179181
fun `stopped for recitation`() =
180-
goldenStreamingFile("streaming-failure-recitation-no-content.txt") {
182+
goldenVertexStreamingFile("streaming-failure-recitation-no-content.txt") {
181183
val responses = model.generateContentStream("prompt")
182184

183185
withTimeout(testTimeout) {
@@ -188,39 +190,39 @@ internal class StreamingSnapshotTests {
188190

189191
@Test
190192
fun `image rejected`() =
191-
goldenStreamingFile("streaming-failure-image-rejected.txt", HttpStatusCode.BadRequest) {
193+
goldenVertexStreamingFile("streaming-failure-image-rejected.txt", HttpStatusCode.BadRequest) {
192194
val responses = model.generateContentStream("prompt")
193195

194196
withTimeout(testTimeout) { shouldThrow<ServerException> { responses.collect() } }
195197
}
196198

197199
@Test
198200
fun `unknown model`() =
199-
goldenStreamingFile("streaming-failure-unknown-model.txt", HttpStatusCode.NotFound) {
201+
goldenVertexStreamingFile("streaming-failure-unknown-model.txt", HttpStatusCode.NotFound) {
200202
val responses = model.generateContentStream("prompt")
201203

202204
withTimeout(testTimeout) { shouldThrow<ServerException> { responses.collect() } }
203205
}
204206

205207
@Test
206208
fun `invalid api key`() =
207-
goldenStreamingFile("streaming-failure-api-key.txt", HttpStatusCode.BadRequest) {
209+
goldenVertexStreamingFile("streaming-failure-api-key.txt", HttpStatusCode.BadRequest) {
208210
val responses = model.generateContentStream("prompt")
209211

210212
withTimeout(testTimeout) { shouldThrow<InvalidAPIKeyException> { responses.collect() } }
211213
}
212214

213215
@Test
214216
fun `invalid json`() =
215-
goldenStreamingFile("streaming-failure-invalid-json.txt") {
217+
goldenVertexStreamingFile("streaming-failure-invalid-json.txt") {
216218
val responses = model.generateContentStream("prompt")
217219

218220
withTimeout(testTimeout) { shouldThrow<SerializationException> { responses.collect() } }
219221
}
220222

221223
@Test
222224
fun `malformed content`() =
223-
goldenStreamingFile("streaming-failure-malformed-content.txt") {
225+
goldenVertexStreamingFile("streaming-failure-malformed-content.txt") {
224226
val responses = model.generateContentStream("prompt")
225227

226228
withTimeout(testTimeout) { shouldThrow<SerializationException> { responses.collect() } }

0 commit comments

Comments
 (0)