Skip to content

Commit fff6709

Browse files
committed
Make all-attribute-types round-trip test total instead of throwing
val r = result.get was evaluated before the result.isDefined check, so a missing item would surface as NoSuchElementException rather than a clean assertion failure. Use result.exists instead.
1 parent c239221 commit fff6709

1 file changed

Lines changed: 22 additions & 24 deletions

File tree

it/src/test/scala/zio/dynamodb/DynamoDBLowLevelApiSpec.scala

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,30 +1007,28 @@ object DynamoDBLowLevelApiSpec extends DynamoDBLocalSpec {
10071007
for {
10081008
_ <- interpreter.run(DynamoDBQuery.putItem(table, item))
10091009
result <- interpreter.run(DynamoDBQuery.getItem(table, PrimaryKey("id" -> "types-all")))
1010-
} yield {
1011-
val r = result.get
1012-
assertTrue(
1013-
result.isDefined &&
1014-
r.getOption[Boolean]("bool").contains(true) &&
1015-
r.getOption[Int]("num").contains(42) &&
1016-
r.getOption[Set[Int]]("numSet").contains(Set(1, 2, 3)) &&
1017-
r.getOption[String]("str").contains("hello") &&
1018-
r.getOption[Set[String]]("strSet").contains(Set("x", "y", "z")) &&
1019-
r.map
1020-
.get("list")
1021-
.collect { case AttributeValue.List(v) =>
1022-
v.collect { case AttributeValue.Number(n) => n.intValue }.toList
1023-
}
1024-
.contains(List(1, 2, 3)) &&
1025-
r.getOption[Map[String, Boolean]]("map").contains(Map("a" -> true, "b" -> false)) &&
1026-
r.map
1027-
.get("bin")
1028-
.collect { case AttributeValue.Binary(b) =>
1029-
b.toList
1030-
}
1031-
.contains(Chunk.fromArray("abc".getBytes).toList)
1032-
)
1033-
}
1010+
} yield assertTrue(
1011+
result.exists { r =>
1012+
r.getOption[Boolean]("bool").contains(true) &&
1013+
r.getOption[Int]("num").contains(42) &&
1014+
r.getOption[Set[Int]]("numSet").contains(Set(1, 2, 3)) &&
1015+
r.getOption[String]("str").contains("hello") &&
1016+
r.getOption[Set[String]]("strSet").contains(Set("x", "y", "z")) &&
1017+
r.map
1018+
.get("list")
1019+
.collect { case AttributeValue.List(v) =>
1020+
v.collect { case AttributeValue.Number(n) => n.intValue }.toList
1021+
}
1022+
.contains(List(1, 2, 3)) &&
1023+
r.getOption[Map[String, Boolean]]("map").contains(Map("a" -> true, "b" -> false)) &&
1024+
r.map
1025+
.get("bin")
1026+
.collect { case AttributeValue.Binary(b) =>
1027+
b.toList
1028+
}
1029+
.contains(Chunk.fromArray("abc".getBytes).toList)
1030+
}
1031+
)
10341032
}
10351033
},
10361034
test("binary set values are preserved after a put/get round-trip") {

0 commit comments

Comments
 (0)