Skip to content

Commit

Permalink
avoid adding !!
Browse files Browse the repository at this point in the history
  • Loading branch information
tanzimfh committed Jul 17, 2024
1 parent 9926154 commit aa1905f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ internal class UnarySnapshotTests {
val response = apiController.generateContent(textGenerateContentRequest("prompt"))
val callPart = (response.candidates!!.first().content!!.parts.first() as FunctionCallPart)

callPart.functionCall.args!!["season"] shouldBe null
callPart.functionCall.args shouldNotBe null
callPart.functionCall.args?.get("season") shouldBe null
}
}

Expand All @@ -333,7 +334,8 @@ internal class UnarySnapshotTests {
it.parts.first().shouldBeInstanceOf<FunctionCallPart>()
}

callPart.functionCall.args!!["current"] shouldBe "true"
callPart.functionCall.args shouldNotBe null
callPart.functionCall.args?.get("current") shouldBe "true"
}
}

Expand All @@ -342,7 +344,9 @@ internal class UnarySnapshotTests {
goldenUnaryFile("success-function-call-empty-arguments.json") {
withTimeout(testTimeout) {
val response = apiController.generateContent(textGenerateContentRequest("prompt"))
val callPart = (response.candidates!!.first().content!!.parts.first() as FunctionCallPart)
val content = response.candidates.shouldNotBeNullOrEmpty().first().content
content.shouldNotBeNull()
val callPart = content.parts.shouldNotBeNullOrEmpty().first() as FunctionCallPart

callPart.functionCall.name shouldBe "current_time"
callPart.functionCall.args shouldBe null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ internal class GenerativeModelTests {
response.functionCalls.firstOrNull()?.let {
it.shouldNotBeNull()
it.name shouldBe "getExchangeRate"
it.args!! shouldContain ("currencyFrom" to "USD")
it.args!! shouldContain ("currencyTo" to "EUR")
it.args.shouldNotBeNull()
it.args?.shouldContain("currencyFrom" to "USD")
it.args?.shouldContain("currencyTo" to "EUR")
}

coEvery { mockApiController.generateContent(any()) } returns
Expand Down

0 comments on commit aa1905f

Please sign in to comment.