@@ -5,6 +5,7 @@ package events
55import (
66 "encoding/base64"
77 "encoding/json"
8+ "fmt"
89 "testing"
910
1011 "github.com/stretchr/testify/assert"
@@ -206,6 +207,7 @@ func TestAccessWithWrongTypePanics(t *testing.T) {
206207 {`{ "N": "123.45"}` , func (av DynamoDBAttributeValue ) { av .Boolean () }, IncompatibleDynamoDBTypeError {Requested : DataTypeBoolean , Actual : DataTypeNumber }},
207208 {`{ "NS": ["1234", "567.8"] }` , func (av DynamoDBAttributeValue ) { av .Boolean () }, IncompatibleDynamoDBTypeError {Requested : DataTypeBoolean , Actual : DataTypeNumberSet }},
208209 {`{ "NULL": true}` , func (av DynamoDBAttributeValue ) { av .Number () }, IncompatibleDynamoDBTypeError {Requested : DataTypeNumber , Actual : DataTypeNull }},
210+ {`{ "BOOL": true}` , func (av DynamoDBAttributeValue ) { av .String () }, IncompatibleDynamoDBTypeError {Requested : DataTypeString , Actual : DataTypeBoolean }},
209211 {`{ "S": "Hello"}` , func (av DynamoDBAttributeValue ) { av .Number () }, IncompatibleDynamoDBTypeError {Requested : DataTypeNumber , Actual : DataTypeString }},
210212 {`{ "SS": [ "Giraffe", "Zebra" ] }` , func (av DynamoDBAttributeValue ) { av .Number () }, IncompatibleDynamoDBTypeError {Requested : DataTypeNumber , Actual : DataTypeStringSet }},
211213 }
@@ -219,6 +221,13 @@ func TestAccessWithWrongTypePanics(t *testing.T) {
219221 }
220222}
221223
224+ func TestDynamoDBAttributeValueGoStringDoesNotCallStringAccessor (t * testing.T ) {
225+ var av DynamoDBAttributeValue
226+ err := json .Unmarshal ([]byte (`{ "BOOL": true}` ), & av )
227+ assert .Nil (t , err )
228+ assert .NotPanics (t , func () { fmt .Sprintf ("%#v" , av ) })
229+ }
230+
222231func TestMarshalAndUnmarshalString (t * testing.T ) {
223232 const inputString = "INPUT STRING"
224233 inputValue := NewStringAttribute (inputString )
0 commit comments