Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace @enumOfCaseObject with @simpleEnum #323

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

grouzen
Copy link
Contributor

@grouzen grouzen commented Nov 14, 2023

/fixes #284

@@ -284,35 +284,20 @@ object ItemDecoderSpec extends ZIOSpecDefault with CodecTestFixtures {

assert(actual)(isRight(equalTo(PreBilled(id = 1, s = "foobar"))))
},
test("decodes case object only enum with @enumOfCaseObjects annotation and without @caseName annotation") {
test("decodes case object only enum with @simpleEnum annotation and without @caseName annotation") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not pretty sure if we need to keep these test cases as it seems they test what was tested by zio-schema.

Comment on lines -301 to -315
test("fails decoding of enum with @enumOfCaseObjects annotation that does not have all case objects") {
val item: Item = Item(Map("enum" -> AttributeValue.String("ONE")))

val actual = DynamoDBQuery.fromItem[WithCaseObjectOnlyEnum2](item)

assert(actual)(
isLeft(
hasMessage(
equalTo(
"Can not decode enum String(ONE) - @enumOfCaseObjects annotation present when all instances are not case objects."
)
)
)
)
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using @simpleEnum checks this in compile time.

Comment on lines -236 to -250
test("fails encoding of enum with @enumOfCaseObjects annotation that does not have all case objects") {

val item = Try(DynamoDBQuery.toItem(WithCaseObjectOnlyEnum2(WithCaseObjectOnlyEnum2.ONE)))

assert(item)(
isFailure(
hasMessage(
equalTo(
"Can not encode enum ONE - @enumOfCaseObjects annotation present when all instances are not case objects."
)
)
)
)
},
test("encodes enum and honours @caseName annotation when there is no @enumOfCaseObjects annotation") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using @simpleEnum checks this in compile time.

Copy link
Contributor

@googley42 googley42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - many thanks for your contribution!

@googley42 googley42 merged commit ffc9fd0 into zio:series/2.x Nov 22, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

integrate with new ZIO Schema simpleEnum annotation
2 participants