@@ -22,12 +22,12 @@ import com.google.firebase.ai.type.ResponseStoppedException
2222import com.google.firebase.ai.type.ServerException
2323import com.google.firebase.ai.util.goldenDevAPIUnaryFile
2424import io.kotest.assertions.throwables.shouldThrow
25+ import io.kotest.matchers.collections.shouldBeEmpty
2526import io.kotest.matchers.collections.shouldNotBeEmpty
2627import io.kotest.matchers.nulls.shouldBeNull
2728import io.kotest.matchers.nulls.shouldNotBeNull
2829import io.kotest.matchers.should
2930import io.kotest.matchers.shouldBe
30- import io.kotest.matchers.shouldNotBe
3131import io.ktor.http.HttpStatusCode
3232import kotlin.time.Duration.Companion.seconds
3333import kotlinx.coroutines.withTimeout
@@ -42,9 +42,24 @@ internal class DevAPIUnarySnapshotTests {
4242 withTimeout(testTimeout) {
4343 val response = model.generateContent(" prompt" )
4444
45- response.candidates.isEmpty() shouldBe false
45+ response.candidates.shouldNotBeEmpty()
4646 response.candidates.first().finishReason shouldBe FinishReason .STOP
47- response.candidates.first().content.parts.isEmpty() shouldBe false
47+ response.candidates.first().content.parts.shouldNotBeEmpty()
48+ }
49+ }
50+
51+ @Test
52+ fun `only prompt feedback reply` () =
53+ goldenDevAPIUnaryFile(" unary-failure-only-prompt-feedback.json" ) {
54+ withTimeout(testTimeout) {
55+ val response = model.generateContent(" prompt" )
56+
57+ response.candidates.shouldBeEmpty()
58+
59+ // Check response from accessors
60+ response.text.shouldBeNull()
61+ response.functionCalls.shouldBeEmpty()
62+ response.inlineDataParts.shouldBeEmpty()
4863 }
4964 }
5065
@@ -54,9 +69,9 @@ internal class DevAPIUnarySnapshotTests {
5469 withTimeout(testTimeout) {
5570 val response = model.generateContent(" prompt" )
5671
57- response.candidates.isEmpty() shouldBe false
72+ response.candidates.shouldNotBeEmpty()
5873 response.candidates.first().finishReason shouldBe FinishReason .STOP
59- response.candidates.first().content.parts.isEmpty() shouldBe false
74+ response.candidates.first().content.parts.shouldNotBeEmpty()
6075 }
6176 }
6277
@@ -66,11 +81,11 @@ internal class DevAPIUnarySnapshotTests {
6681 withTimeout(testTimeout) {
6782 val response = model.generateContent(" prompt" )
6883
69- response.candidates.isEmpty() shouldBe false
84+ response.candidates.shouldNotBeEmpty()
7085 response.candidates.first().citationMetadata?.citations?.size shouldBe 4
7186 response.candidates.first().citationMetadata?.citations?.forEach {
72- it.startIndex shouldNotBe null
73- it.endIndex shouldNotBe null
87+ it.startIndex.shouldNotBeNull()
88+ it.endIndex.shouldNotBeNull()
7489 }
7590 }
7691 }
0 commit comments