-
Notifications
You must be signed in to change notification settings - Fork 18
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
Conversation
@@ -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") { |
There was a problem hiding this comment.
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.
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." | ||
) | ||
) | ||
) | ||
) | ||
}, |
There was a problem hiding this comment.
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.
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") { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
/fixes #284