Skip to content

Commit

Permalink
Fix code remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
dbulaja98 committed Dec 10, 2022
1 parent 91aa695 commit 6dc438c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package zio.elasticsearch

import zio.elasticsearch.ElasticError.DocumentRetrievingError.{DecoderError, DocumentNotFound}
import zio.test.Assertion.equalTo
import zio.test.Assertion.{equalTo, isUnit}
import zio.test.TestAspect.nondeterministic
import zio.test._

Expand Down Expand Up @@ -37,7 +37,7 @@ object HttpExecutorSpec extends IntegrationSpec {
assertZIO(result)(Assertion.isLeft(equalTo(DecoderError(".address(missing)"))))
}
}
) @@ nondeterministic,
),
suite("creating document")(
test("successfully create document") {
checkOnce(genCustomer) { customer =>
Expand Down Expand Up @@ -65,7 +65,7 @@ object HttpExecutorSpec extends IntegrationSpec {
assertZIO(result)(Assertion.isRight(equalTo(customer1)))
}
}
) @@ nondeterministic,
),
suite("creating or updating document")(
test("successfully create document") {
checkOnce(genDocumentId, genCustomer) { (documentId, customer) =>
Expand All @@ -80,15 +80,15 @@ object HttpExecutorSpec extends IntegrationSpec {
test("successfully update document") {
checkOnce(genDocumentId, genCustomer, genCustomer) { (documentId, customer1, customer2) =>
val result = for {
_ <- ElasticRequest.upsert[CustomerDocument](index, documentId, customer1).execute
_ <- ElasticRequest.create[CustomerDocument](index, documentId, customer1).execute
_ <- ElasticRequest.upsert[CustomerDocument](index, documentId, customer2).execute
doc <- ElasticRequest.getById[CustomerDocument](index, documentId).execute
} yield doc

assertZIO(result)(Assertion.isRight(equalTo(customer2)))
}
}
) @@ nondeterministic,
),
suite("finding document")(
test("return true if the document exists") {
checkOnce(genDocumentId, genCustomer) { (documentId, customer) =>
Expand All @@ -105,7 +105,7 @@ object HttpExecutorSpec extends IntegrationSpec {
assertZIO(ElasticRequest.exists(index, documentId).execute)(equalTo(false))
}
}
) @@ nondeterministic,
),
suite("deleting document by ID")(
test("return unit if document deletion was successful") {
checkOnce(genDocumentId, genCustomer) { (documentId, customer) =>
Expand All @@ -114,7 +114,7 @@ object HttpExecutorSpec extends IntegrationSpec {
res <- ElasticRequest.deleteById(index, documentId).execute
} yield res

assertZIO(result)(Assertion.isRight(equalTo(())))
assertZIO(result)(Assertion.isRight(isUnit))
}
},
test("return DocumentNotFound if the document does not exist") {
Expand All @@ -126,20 +126,20 @@ object HttpExecutorSpec extends IntegrationSpec {
assertZIO(result)(Assertion.isLeft(equalTo(DocumentNotFound)))
}
}
) @@ nondeterministic,
),
suite("creating index")(
test("return unit if creation was successful") {
checkOnce(genIndexName) { indexName =>
assertZIO(ElasticRequest.createIndex(indexName, None).execute)(equalTo(()))
}
}
) @@ nondeterministic,
),
suite("delete index")(
test("return unit if deletion was successful") {
checkOnce(genIndexName) { indexName =>
assertZIO(ElasticRequest.deleteIndex(indexName).execute)(equalTo(()))
}
}
) @@ nondeterministic
).provideShared(elasticsearchLayer)
)
).provideShared(elasticsearchLayer) @@ nondeterministic
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait IntegrationSpec extends ZIOSpecDefault {
val index: IndexName = IndexName("users")

def genIndexName: Gen[Any, IndexName] =
Gen.stringBounded(10, 40)(Gen.alphaChar).map(name => unsafeWrap(IndexName)(name))
Gen.stringBounded(10, 40)(Gen.alphaChar).map(unsafeWrap(IndexName)(_))

def genDocumentId: Gen[Any, DocumentId] = Gen.stringBounded(10, 40)(Gen.alphaNumericChar).map(DocumentId(_))

Expand Down

0 comments on commit 6dc438c

Please sign in to comment.