Skip to content

Commit

Permalink
test: apply style guide
Browse files Browse the repository at this point in the history
  • Loading branch information
masonJS committed Sep 30, 2023
1 parent af8c834 commit 0e0f74a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({
WildcardSearchOperatorDsl().apply(block)

"allowAnalyzedField" - {
"should set with given value" {
"should build an option with given value" {
// given
val operator = wildcard {
allowAnalyzedField = true
Expand All @@ -32,7 +32,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({
}

"query" - {
"should set query by string" {
"should build a query by string" {
// given
val operator = wildcard {
query("query")
Expand All @@ -53,7 +53,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({
)
}

"should set query by multiple strings" {
"should build a query by multiple strings" {
// given
val operator = wildcard {
query("query1", "query2")
Expand All @@ -79,7 +79,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({
}

"path" - {
"should set path by strings" {
"should build a path by strings" {
// given
val operator = wildcard {
path("path1", "path2")
Expand All @@ -103,7 +103,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({
)
}

"should set path by iterable property" {
"should build a path by iterable property" {
// given
data class TestCollection(val path1: List<String>)
val operator = wildcard {
Expand All @@ -125,7 +125,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({
)
}

"should set path by multiple properties" {
"should build a path by multiple properties" {
// given
data class TestCollection(val path1: String, val path2: String)
val operator = wildcard {
Expand All @@ -150,7 +150,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({
)
}

"should set path by nested property" {
"should build a path by nested property" {
// given
data class Child(val path: String)
data class Parent(val child: Child)
Expand All @@ -173,7 +173,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({
)
}

"should set path by option block" {
"should build a path by option block" {
// given
data class TestCollection(val path1: String, val path2: List<String>)
val operator = wildcard {
Expand Down Expand Up @@ -205,7 +205,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({
}

"score" - {
"should set score" {
"should build a score" {
// given
val operator = wildcard {
score {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.inflab.example.spring.data.mongodb.repository
package com.github.inflab.example.spring.data.mongodb.repository.atlas

import com.github.inflab.example.spring.data.mongodb.entity.mflix.Movies
import com.github.inflab.spring.data.mongodb.core.aggregation.aggregation
Expand Down Expand Up @@ -44,6 +44,9 @@ class WildcardSearchRepository(
query("*\\?")
}
}

// TODO: add $limit stage

project {
excludeId()
+Movies::title
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.github.inflab.example.spring.data.mongodb.repository
package com.github.inflab.example.spring.data.mongodb.repository.atlas

import com.github.inflab.example.spring.data.mongodb.extension.AtlasTest
import io.kotest.core.annotation.Ignored
import io.kotest.core.spec.style.FreeSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldContain

@Ignored
@AtlasTest(database = "sample_mflix")
internal class WildcardSearchRepositoryTest(
private val wildcardSearchRepository: WildcardSearchRepository,
Expand All @@ -28,6 +25,12 @@ internal class WildcardSearchRepositoryTest(
val result = wildcardSearchRepository.findTitleWithQuestionMark()

// then
result.mappedResults.map { it.title shouldContain "?" }
result.mappedResults.take(5).map { it.title } shouldBe listOf(
"Where Are My Children?",
"Who Killed Cock Robin?",
"What's Opera, Doc?",
"Will Success Spoil Rock Hunter?",
"Who Was That Lady?",
)
}
})

0 comments on commit 0e0f74a

Please sign in to comment.