Created
October 25, 2015 10:23
-
-
Save nabeken/709933249a58b6477e85 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add conditon and it should fail | |
{ | |
err := dtable.PutItem( | |
items[0], | |
option.PutExpressionAttributeName("date", "#date"), | |
option.PutCondition("attribute_not_exists(#date)"), | |
) | |
assert.Error(err) | |
dynamoErr, ok := err.(awserr.Error) | |
assert.True(ok, "err must be awserr.Error") | |
assert.Equal("ConditionalCheckFailedException", dynamoErr.Code()) | |
} | |
// Update the item with incrementing counter and setting role as StringSet | |
{ | |
err := dtable.UpdateItem( | |
hashKey, | |
rangeKey, | |
option.UpdateExpressionAttributeName("login_count", "#count"), | |
option.UpdateExpressionAttributeName("role", "#role"), | |
option.UpdateExpressionAttributeValue(":i", attributes.Number(1)), | |
option.UpdateExpressionAttributeValue(":role", attributes.StringSet(role)), | |
option.UpdateExpression("ADD #count :i SET #role = :role"), | |
) | |
if err != nil { | |
t.Error(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment