Skip to content

Commit

Permalink
Merge branch 'master' into multi-table-transact
Browse files Browse the repository at this point in the history
  • Loading branch information
purkhusid committed Oct 14, 2024
2 parents 026cf02 + b5bcf15 commit 91c4377
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/FSharp.AWS.DynamoDB/Picklers/PrimitivePicklers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ type StringPickler() =
override _.Pickle s =
if isNull s then
AttributeValue(NULL = true)
elif s = "" then
invalidOp "empty strings not supported by DynamoDB."
else
AttributeValue(s)
|> Some
Expand Down
4 changes: 1 addition & 3 deletions tests/FSharp.AWS.DynamoDB.Tests/RecordGenerationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ module ``Record Generation Tests`` =
test <@ r' = r @>
with
// account for random inputs not supported by the library
| :? InvalidOperationException as e when e.Message = "empty strings not supported by DynamoDB." -> ()
| :? ArgumentException as e when
e.Message.Contains "unsupported key name" && e.Message.Contains "should be 1 to 64k long (as utf8)"
->
e.Message.Contains "unsupported key name" && e.Message.Contains "should be 1 to 64k long (as utf8)" ->
()

Check.One(config, roundTrip)
Expand Down
21 changes: 21 additions & 0 deletions tests/FSharp.AWS.DynamoDB.Tests/SimpleTableOperationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module SimpleTableTypes =
[<RangeKey>]
RangeKey: string

EmptyString: string

Value: int64

Tuple: int64 * int64
Expand Down Expand Up @@ -46,6 +48,7 @@ type ``Simple Table Operation Tests``(fixture: TableFixture) =
let mkItem () =
{ HashKey = guid ()
RangeKey = guid ()
EmptyString = ""
Value = rand ()
Tuple = rand (), rand ()
Map = seq { for _ in 0L .. rand () % 5L -> "K" + guid (), rand () } |> Map.ofSeq
Expand Down Expand Up @@ -131,6 +134,23 @@ type ``Simple Table Operation Tests``(fixture: TableFixture) =
test <@ None = deletedItem @>
test <@ not (table.ContainsKey key) @>

[<Theory>]
[<InlineData("",
"rangeKey",
"One or more parameter values are not valid. The AttributeValue for a key attribute cannot contain an empty string value. Key: HashKey")>]
[<InlineData("hashKey",
"",
"One or more parameter values are not valid. The AttributeValue for a key attribute cannot contain an empty string value. Key: RangeKey")>]
[<InlineData("",
"",
"One or more parameter values are not valid. The AttributeValue for a key attribute cannot contain an empty string value. Key: HashKey")>]
let ``Operations with empty key values should fail with a DynamoDB client error`` (hashKey, rangeKey, expectedErrorMsg) =
let value = { mkItem () with HashKey = hashKey; RangeKey = rangeKey }
try
table.PutItem value |> ignore
with :? Amazon.DynamoDBv2.AmazonDynamoDBException as ex ->
test <@ ex.Message = expectedErrorMsg @>

interface IClassFixture<TableFixture>

type ``TransactWriteItems tests``(table1: TableFixture, table2: TableFixture) =
Expand All @@ -140,6 +160,7 @@ type ``TransactWriteItems tests``(table1: TableFixture, table2: TableFixture) =
let mkItem () =
{ HashKey = guid ()
RangeKey = guid ()
EmptyString = ""
Value = randInt64 ()
Tuple = randInt64 (), randInt64 ()
Map = seq { for _ in 0L .. randInt64 () % 5L -> "K" + guid (), randInt64 () } |> Map.ofSeq
Expand Down

0 comments on commit 91c4377

Please sign in to comment.