Skip to content

Commit

Permalink
Apply spotless formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tomascayuelas authored and github-actions[bot] committed Dec 1, 2023
1 parent fb32acb commit bed6f58
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import io.kotest.assertions.json.shouldEqualJson
import io.kotest.common.runBlocking
import io.kotest.matchers.shouldBe
import io.kotest.property.arbitrary.next
import kotlinx.coroutines.test.runTest
import kotlin.io.path.absolutePathString
import kotlin.io.path.createTempDirectory
import kotlin.io.path.listDirectoryEntries
import kotlin.test.Test
import kotlinx.coroutines.test.runTest

class EitherOpsSpec {
private val validSuiteSpec = runBlocking {
Expand Down Expand Up @@ -54,14 +54,14 @@ class EitherOpsSpec {
fun shouldSerializeToJsonTheAccumulatedErrors() = runTest {
val invalidJsonSuiteSpec =
SuiteSpec(emptyString.next()) {
outputDescription { emptyString.next() }
outputDescription { emptyString.next() }
outputDescription { emptyString.next() }
outputDescription { emptyString.next() }

itemSpec(emptyString.next()) {
contextDescription { emptyString.next() }
outputResponse { emptyString.next() }
itemSpec(emptyString.next()) {
contextDescription { emptyString.next() }
outputResponse { emptyString.next() }
}
}
}
.toJson()

val expectedStringJson =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import com.xebia.functional.xef.evaluator.models.errors.ValidationError
import io.kotest.assertions.arrow.core.shouldBeLeft
import io.kotest.matchers.collections.shouldContainAll
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlinx.coroutines.test.runTest

class ItemSpecBuilderSpec {

Expand Down Expand Up @@ -160,11 +160,6 @@ class ItemSpecBuilderSpec {
}

invalidItemSpec shouldBeLeft
listOf(
EmptyItemSpecInput,
EmptyContextDescription,
EmptyOutputResponse,
EmptyOutputResponse
)
listOf(EmptyItemSpecInput, EmptyContextDescription, EmptyOutputResponse, EmptyOutputResponse)
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.xebia.functional.xef.evaluator

import com.xebia.functional.xef.evaluator.models.SuiteSpec
import com.xebia.functional.xef.evaluator.models.errors.MoreOutputsDescriptionThanItemsSpec
import com.xebia.functional.xef.evaluator.models.errors.LessOutputsDescriptionThanItemsSpec
import com.xebia.functional.xef.evaluator.models.errors.EmptyItemSpecOutputResponse
import com.xebia.functional.xef.evaluator.models.errors.EmptySuiteSpecDescription
import com.xebia.functional.xef.evaluator.models.errors.EmptySuiteSpecOutputDescription
import com.xebia.functional.xef.evaluator.models.errors.InvalidNumberOfItemSpecOutputResponse
import com.xebia.functional.xef.evaluator.models.errors.EmptySuiteSpecDescription
import com.xebia.functional.xef.evaluator.models.errors.LessOutputsDescriptionThanItemsSpec
import com.xebia.functional.xef.evaluator.models.errors.MoreOutputsDescriptionThanItemsSpec
import com.xebia.functional.xef.evaluator.models.errors.OutputsDescriptionNotProvided
import com.xebia.functional.xef.evaluator.models.errors.ValidationError
import com.xebia.functional.xef.evaluator.utils.Generators.emptyString
Expand All @@ -15,180 +15,191 @@ import io.kotest.assertions.arrow.core.shouldBeLeft
import io.kotest.assertions.arrow.core.shouldBeRight
import io.kotest.matchers.shouldBe
import io.kotest.property.arbitrary.next
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlinx.coroutines.test.runTest

class SuiteBuilderSpec {
@Test
fun shouldBuildValidSuiteSpec() = runTest {
SuiteSpec(simpleString.next()) {
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}
}.shouldBeRight()
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}
}
.shouldBeRight()
}

@Test
fun shouldInvalidWithEmptyDescription() = runTest {
val emptyDescription = emptyString.next()

SuiteSpec(emptyDescription) {
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}
}
}.shouldBeLeft() shouldBe listOf<ValidationError>(EmptySuiteSpecDescription)
.shouldBeLeft() shouldBe listOf<ValidationError>(EmptySuiteSpecDescription)
}

@Test
fun shouldInvalidWithoutOutputDescriptionProvided() = runTest {
SuiteSpec(simpleString.next()) {
// no output description provided ...
itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}
}.shouldBeLeft() shouldBe listOf(OutputsDescriptionNotProvided)
// no output description provided ...
itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}
}
.shouldBeLeft() shouldBe listOf(OutputsDescriptionNotProvided)
}

@Test
fun shouldInvalidWithMoreOutputsDescriptionsThatItemsSpec() = runTest {
SuiteSpec(simpleString.next()) {
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }

itemSpec("Please provide a movie title") {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
itemSpec("Please provide a movie title") {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}
}
}.shouldBeLeft() shouldBe listOf(MoreOutputsDescriptionThanItemsSpec)
.shouldBeLeft() shouldBe listOf(MoreOutputsDescriptionThanItemsSpec)
}

@Test
fun shouldInvalidWithLessOutputsDescriptionThanItemsSpec() = runTest {
SuiteSpec(simpleString.next()) {
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}
itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}
}
}.shouldBeLeft() shouldBe listOf(LessOutputsDescriptionThanItemsSpec)
.shouldBeLeft() shouldBe listOf(LessOutputsDescriptionThanItemsSpec)
}

@Test
fun shouldInvalidWithEmptyOutputDescriptionAtIndexCeroAndOne() = runTest {
val emptyOutputDescription = emptyString.next()

SuiteSpec(simpleString.next()) {
outputDescription { emptyOutputDescription }
outputDescription { emptyOutputDescription }
outputDescription { simpleString.next() }

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}
}.shouldBeLeft() shouldBe listOf(
EmptySuiteSpecOutputDescription(0),
EmptySuiteSpecOutputDescription(1),
InvalidNumberOfItemSpecOutputResponse(0),
InvalidNumberOfItemSpecOutputResponse(1),
InvalidNumberOfItemSpecOutputResponse(2)
)
outputDescription { emptyOutputDescription }
outputDescription { emptyOutputDescription }
outputDescription { simpleString.next() }

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}
}
.shouldBeLeft() shouldBe
listOf(
EmptySuiteSpecOutputDescription(0),
EmptySuiteSpecOutputDescription(1),
InvalidNumberOfItemSpecOutputResponse(0),
InvalidNumberOfItemSpecOutputResponse(1),
InvalidNumberOfItemSpecOutputResponse(2)
)
}

@Test
fun shouldInvalidWithOneItemSpecWithoutOneOutPutResponse() = runTest {
SuiteSpec(simpleString.next()) {
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}
itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}
}
}.shouldBeLeft() shouldBe listOf<ValidationError>(InvalidNumberOfItemSpecOutputResponse(0))
.shouldBeLeft() shouldBe listOf<ValidationError>(InvalidNumberOfItemSpecOutputResponse(0))
}

@Test
fun shouldInvalidWithTwoItemsSpecWithoutOneOutputResponse() = runTest {
SuiteSpec(simpleString.next()) {
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}
}.shouldBeLeft() shouldBe listOf<ValidationError>(
InvalidNumberOfItemSpecOutputResponse(0),
InvalidNumberOfItemSpecOutputResponse(1),
)
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
}
}
.shouldBeLeft() shouldBe
listOf<ValidationError>(
InvalidNumberOfItemSpecOutputResponse(0),
InvalidNumberOfItemSpecOutputResponse(1),
)
}

@Test
fun shouldInvalidWithOneItemSpecWithEmptyOutputResponse() = runTest {
val emptyOutputResponse = emptyString.next()

SuiteSpec(simpleString.next()) {
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { emptyOutputResponse }
}
}.shouldBeLeft() shouldBe listOf<ValidationError>(EmptyItemSpecOutputResponse(1))
outputDescription { simpleString.next() }
outputDescription { simpleString.next() }

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { simpleString.next() }
}

itemSpec(simpleString.next()) {
contextDescription { simpleString.next() }
outputResponse { simpleString.next() }
outputResponse { emptyOutputResponse }
}
}
.shouldBeLeft() shouldBe listOf<ValidationError>(EmptyItemSpecOutputResponse(1))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import com.xebia.functional.xef.evaluator.utils.Generators.simpleString
import io.kotest.assertions.arrow.core.shouldBeLeft
import io.kotest.assertions.arrow.core.shouldBeRight
import io.kotest.property.arbitrary.next
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlinx.coroutines.test.runTest

class TestModelsSpec {

Expand Down

0 comments on commit bed6f58

Please sign in to comment.