Skip to content

Commit

Permalink
top level get example
Browse files Browse the repository at this point in the history
  • Loading branch information
googley42 committed Sep 9, 2024
1 parent e5efa29 commit 723e11a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions dynamodb/src/it/scala/zio/dynamodb/TypeSafeApiMappingSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,22 @@ object TypeSafeApiMappingSpec extends DynamoDBLocalSpec {
) @@ TestAspect.nondeterministic

val topLevelSumTypeDiscriminatorNameSuite = suite("with @discriminatorName annotation")(
test("get of top level Invoice type") {
withSingleIdKeyTable { invoiceTable =>
for {
_ <- put[InvoiceWithDiscriminatorName](invoiceTable, InvoiceWithDiscriminatorName.Unpaid("1")).execute
invoice <- // invoice is of type InvoiceWithDiscriminatorName
get[InvoiceWithDiscriminatorName](invoiceTable)(
((InvoiceWithDiscriminatorName.unpaid) >>> (InvoiceWithDiscriminatorName.Unpaid.id)).partitionKey === "1"
).execute.absolve
} yield assertTrue(invoice == InvoiceWithDiscriminatorName.Unpaid("1"))
}
},
test("get of Invoice sub type Unpaid") {
withSingleIdKeyTable { invoiceTable =>
for {
_ <- put[InvoiceWithDiscriminatorName](invoiceTable, InvoiceWithDiscriminatorName.Unpaid("1")).execute
invoice <- get(invoiceTable)(
invoice <- get(invoiceTable)( // invoice is of type InvoiceWithDiscriminatorName.Unpaid
(InvoiceWithDiscriminatorName.Unpaid.id).partitionKey === "1"
).execute.absolve
} yield assertTrue(invoice == InvoiceWithDiscriminatorName.Unpaid("1"))
Expand All @@ -79,7 +90,7 @@ object TypeSafeApiMappingSpec extends DynamoDBLocalSpec {
withSingleIdKeyTable { invoiceTable =>
for {
_ <- put[InvoiceWithDiscriminatorName](invoiceTable, InvoiceWithDiscriminatorName.Paid("1", 42)).execute
invoice <- get(invoiceTable)(
invoice <- get(invoiceTable)( // invoice is of type InvoiceWithDiscriminatorName.Paid
(InvoiceWithDiscriminatorName.Paid.id).partitionKey === "1"
).execute.absolve
} yield assertTrue(invoice == InvoiceWithDiscriminatorName.Paid("1", 42))
Expand Down

0 comments on commit 723e11a

Please sign in to comment.