Skip to content

Commit

Permalink
refactor: use assert.PanicsWithValue (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
wafuwafu13 authored Dec 22, 2023
1 parent c42f056 commit f079271
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions events/attributevalue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,25 +215,10 @@ func TestAccessWithWrongTypePanics(t *testing.T) {
var av DynamoDBAttributeValue
err := json.Unmarshal([]byte(testCase.input), &av)
assert.Nil(t, err)
// may use PanicsWithValue(expectedError) when it is available
assertPanicsWithValue(t, testCase.expectedError, func() { testCase.accessor(av) })
assert.PanicsWithValue(t, testCase.expectedError, func() { testCase.accessor(av) })
}
}

func assertPanicsWithValue(t *testing.T, expected error, action func()) {
defer func() {
r := recover()
if r == nil {
t.Errorf("Should have panicked")
}
if r != expected {
t.Errorf("should have panicked with value %v but panicked with value %v", expected, r)
}
}()

action()
}

func TestMarshalAndUnmarshalString(t *testing.T) {
const inputString = "INPUT STRING"
inputValue := NewStringAttribute(inputString)
Expand Down

0 comments on commit f079271

Please sign in to comment.