diff --git a/openai-client/openai-client-core/src/jvmTest/kotlin/com/tddworks/openai/api/legacy/completions/api/CompletionTest.kt b/openai-client/openai-client-core/src/jvmTest/kotlin/com/tddworks/openai/api/legacy/completions/api/CompletionTest.kt index f78bb08..53f02a6 100644 --- a/openai-client/openai-client-core/src/jvmTest/kotlin/com/tddworks/openai/api/legacy/completions/api/CompletionTest.kt +++ b/openai-client/openai-client-core/src/jvmTest/kotlin/com/tddworks/openai/api/legacy/completions/api/CompletionTest.kt @@ -6,6 +6,47 @@ import org.junit.jupiter.api.Test class CompletionTest { + @Test + fun `should return dummy completion`() { + val completion = Completion.dummy() + + with(completion) { + assertEquals("id", id) + assertEquals(0, created) + assertEquals("model", model) + assertEquals("systemFingerprint", systemFingerprint) + assertEquals("object", `object`) + assertNotNull(usage) + } + } + + @Test + fun `should return completion with required fields`() { + val completion = Completion( + id = "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7", + choices = listOf( + CompletionChoice( + text = "\n\nThis is indeed a test", + index = 0 + ) + ), + created = 1589478378, + model = "gpt-3.5-turbo-instruct" + ) + + with(completion) { + assertEquals("cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7", id) + assertEquals(1589478378, created) + assertEquals("gpt-3.5-turbo-instruct", model) + assertEquals(1, choices.size) + assertEquals("\n\nThis is indeed a test", choices[0].text) + assertEquals(0, choices[0].index) + assertEquals("", choices[0].finishReason) + assertNull(choices[0].logprobs) + assertNull(usage) + } + } + @Test fun `should return completion`() { val completionJson = """