11package scynamo
22
3- import software .amazon .awssdk .services .dynamodb .model .{AttributeValue , GetItemResponse , QueryResponse }
3+ import software .amazon .awssdk .services .dynamodb .model .{AttributeValue , GetItemResponse , QueryResponse , ScanResponse }
44
55class ScynamoTest extends UnitTest {
66 " Scynamo" should {
@@ -23,6 +23,16 @@ class ScynamoTest extends UnitTest {
2323 result should === (Right (List .empty))
2424 }
2525
26+ " return an empty List if the scan response has no items" in {
27+ val response = ScanResponse .builder().build()
28+
29+ val result = for {
30+ result <- Scynamo .decodeScanResponse[Map [String , AttributeValue ]](response)
31+ } yield result
32+
33+ result should === (Right (List .empty))
34+ }
35+
2636 " return the decoded result if it has an item that is well formed" in {
2737 import scynamo .syntax .encoder ._
2838 val input = Map (" foo" -> " bar" )
@@ -36,7 +46,7 @@ class ScynamoTest extends UnitTest {
3646 result should === (Right (Some (input)))
3747 }
3848
39- " return the decoded result if it has multiple items that are well formed" in {
49+ " return the decoded query result if it has multiple items that are well formed" in {
4050 import scynamo .syntax .encoder ._
4151 val input1 = Map (" foo" -> " bar" )
4252 val input2 = Map (" Miami" -> " Ibiza" )
@@ -49,5 +59,19 @@ class ScynamoTest extends UnitTest {
4959 } yield result
5060 result should === (Right (List (input1, input2)))
5161 }
62+
63+ " return the decoded scan result if it has multiple items that are well formed" in {
64+ import scynamo .syntax .encoder ._
65+ val input1 = Map (" foo" -> " bar" )
66+ val input2 = Map (" Miami" -> " Ibiza" )
67+
68+ val result = for {
69+ encodedInput1 <- input1.encodedMap
70+ encodedInput2 <- input2.encodedMap
71+ response = ScanResponse .builder().items(encodedInput1, encodedInput2).build()
72+ result <- Scynamo .decodeScanResponse[Map [String , String ]](response)
73+ } yield result
74+ result should === (Right (List (input1, input2)))
75+ }
5276 }
5377}
0 commit comments