@@ -22,12 +22,12 @@ import com.google.firebase.ai.type.ResponseStoppedException
22
22
import com.google.firebase.ai.type.ServerException
23
23
import com.google.firebase.ai.util.goldenDevAPIUnaryFile
24
24
import io.kotest.assertions.throwables.shouldThrow
25
+ import io.kotest.matchers.collections.shouldBeEmpty
25
26
import io.kotest.matchers.collections.shouldNotBeEmpty
26
27
import io.kotest.matchers.nulls.shouldBeNull
27
28
import io.kotest.matchers.nulls.shouldNotBeNull
28
29
import io.kotest.matchers.should
29
30
import io.kotest.matchers.shouldBe
30
- import io.kotest.matchers.shouldNotBe
31
31
import io.ktor.http.HttpStatusCode
32
32
import kotlin.time.Duration.Companion.seconds
33
33
import kotlinx.coroutines.withTimeout
@@ -42,9 +42,24 @@ internal class DevAPIUnarySnapshotTests {
42
42
withTimeout(testTimeout) {
43
43
val response = model.generateContent(" prompt" )
44
44
45
- response.candidates.isEmpty() shouldBe false
45
+ response.candidates.shouldNotBeEmpty()
46
46
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()
48
63
}
49
64
}
50
65
@@ -54,9 +69,9 @@ internal class DevAPIUnarySnapshotTests {
54
69
withTimeout(testTimeout) {
55
70
val response = model.generateContent(" prompt" )
56
71
57
- response.candidates.isEmpty() shouldBe false
72
+ response.candidates.shouldNotBeEmpty()
58
73
response.candidates.first().finishReason shouldBe FinishReason .STOP
59
- response.candidates.first().content.parts.isEmpty() shouldBe false
74
+ response.candidates.first().content.parts.shouldNotBeEmpty()
60
75
}
61
76
}
62
77
@@ -66,11 +81,11 @@ internal class DevAPIUnarySnapshotTests {
66
81
withTimeout(testTimeout) {
67
82
val response = model.generateContent(" prompt" )
68
83
69
- response.candidates.isEmpty() shouldBe false
84
+ response.candidates.shouldNotBeEmpty()
70
85
response.candidates.first().citationMetadata?.citations?.size shouldBe 4
71
86
response.candidates.first().citationMetadata?.citations?.forEach {
72
- it.startIndex shouldNotBe null
73
- it.endIndex shouldNotBe null
87
+ it.startIndex.shouldNotBeNull()
88
+ it.endIndex.shouldNotBeNull()
74
89
}
75
90
}
76
91
}
0 commit comments