Skip to content

Commit 554303c

Browse files
authored
replace bespoke json comparison helper with JSONEq from testify (#148)
1 parent 9e3676e commit 554303c

19 files changed

+42
-176
lines changed

events/apigw_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"testing"
99

1010
"github.com/aws/aws-lambda-go/events/test"
11+
"github.com/stretchr/testify/assert"
1112
)
1213

1314
func TestApiGatewayRequestMarshaling(t *testing.T) {
@@ -38,7 +39,7 @@ func TestApiGatewayRequestMarshaling(t *testing.T) {
3839
t.Errorf("could not marshal event. details: %v", err)
3940
}
4041

41-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
42+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
4243
}
4344

4445
func TestApiGatewayRequestMalformedJson(t *testing.T) {
@@ -65,7 +66,7 @@ func TestApiGatewayResponseMarshaling(t *testing.T) {
6566
t.Errorf("could not marshal event. details: %v", err)
6667
}
6768

68-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
69+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
6970
}
7071

7172
func TestApiGatewayResponseMalformedJson(t *testing.T) {
@@ -92,7 +93,7 @@ func TestApiGatewayCustomAuthorizerRequestMarshaling(t *testing.T) {
9293
t.Errorf("could not marshal event. details: %v", err)
9394
}
9495

95-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
96+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
9697
}
9798

9899
func TestApiGatewayCustomAuthorizerRequestTypeRequestMarshaling(t *testing.T) {
@@ -115,7 +116,7 @@ func TestApiGatewayCustomAuthorizerRequestTypeRequestMarshaling(t *testing.T) {
115116
t.Errorf("could not marshal event. details: %v", err)
116117
}
117118

118-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
119+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
119120
}
120121

121122
func TestApiGatewayCustomAuthorizerRequestMalformedJson(t *testing.T) {
@@ -146,7 +147,7 @@ func TestApiGatewayCustomAuthorizerResponseMarshaling(t *testing.T) {
146147
t.Errorf("could not marshal event. details: %v", err)
147148
}
148149

149-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
150+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
150151
}
151152

152153
func TestApiGatewayCustomAuthorizerResponseMalformedJson(t *testing.T) {

events/appsync_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"io/ioutil"
66
"testing"
77

8-
"github.com/aws/aws-lambda-go/events/test"
98
"github.com/stretchr/testify/assert"
109
)
1110

@@ -26,7 +25,7 @@ func TestAppSyncResolverTemplate_invoke(t *testing.T) {
2625
t.Errorf("could not marshal event. details: %v", err)
2726
}
2827

29-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
28+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
3029
}
3130

3231
func TestAppSyncResolverTemplate_batchinvoke(t *testing.T) {
@@ -46,5 +45,5 @@ func TestAppSyncResolverTemplate_batchinvoke(t *testing.T) {
4645
t.Errorf("could not marshal event. details: %v", err)
4746
}
4847

49-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
48+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
5049
}

events/autoscaling_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package events
22

33
import (
44
"encoding/json"
5-
"github.com/aws/aws-lambda-go/events/test"
65
"testing"
6+
7+
"github.com/aws/aws-lambda-go/events/test"
8+
"github.com/stretchr/testify/assert"
79
)
810

911
func TestAutoScalingEventMarshaling(t *testing.T) {
@@ -29,7 +31,7 @@ func TestAutoScalingEventMarshaling(t *testing.T) {
2931
t.Errorf("could not marshal event. details: %v", err)
3032
}
3133
// 4. check result
32-
test.AssertJsonsEqual(t, inputJson, outputJson)
34+
assert.JSONEq(t, string(inputJson), string(outputJson))
3335
}
3436

3537
}

events/cloudwatch_events_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/aws/aws-lambda-go/events/test"
8+
"github.com/stretchr/testify/assert"
89
)
910

1011
func TestCloudwatchScheduledEventIdempotency(t *testing.T) {
@@ -27,7 +28,7 @@ func TestCloudwatchScheduledEventIdempotency(t *testing.T) {
2728
t.Errorf("Could not marshal scheduled event: %v", err)
2829
}
2930

30-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
31+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
3132
}
3233

3334
func TestCloudwatchScheduledEventRequestMalformedJson(t *testing.T) {

events/codepipeline_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/aws/aws-lambda-go/events/test"
10+
"github.com/stretchr/testify/assert"
1011
)
1112

1213
func TestCodePipeLineEventMarshaling(t *testing.T) {
@@ -29,7 +30,7 @@ func TestCodePipeLineEventMarshaling(t *testing.T) {
2930
t.Errorf("could not marshal event. details: %v", err)
3031
}
3132

32-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
33+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
3334
}
3435

3536
func TestCodePipelineEventMarshalingMalformedJson(t *testing.T) {

events/cognito_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/aws/aws-lambda-go/events/test"
10+
"github.com/stretchr/testify/assert"
1011
)
1112

1213
func TestCognitoEventMarshaling(t *testing.T) {
@@ -29,7 +30,7 @@ func TestCognitoEventMarshaling(t *testing.T) {
2930
t.Errorf("could not marshal event. details: %v", err)
3031
}
3132

32-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
33+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
3334
}
3435

3536
func TestCognitoMarshalingMalformedJson(t *testing.T) {
@@ -56,7 +57,7 @@ func TestCognitoEventUserPoolsPreSignupMarshaling(t *testing.T) {
5657
t.Errorf("could not marshal event. details: %v", err)
5758
}
5859

59-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
60+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
6061
}
6162

6263
func TestCognitoUserPoolsPreSignupMarshalingMalformedJson(t *testing.T) {
@@ -83,7 +84,7 @@ func TestCognitoEventUserPoolsPostConfirmationMarshaling(t *testing.T) {
8384
t.Errorf("could not marshal event. details: %v", err)
8485
}
8586

86-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
87+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
8788
}
8889

8990
func TestCognitoEventUserPoolsPreTokenGenMarshalingMalformedJson(t *testing.T) {

events/config_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/aws/aws-lambda-go/events/test"
10+
"github.com/stretchr/testify/assert"
1011
)
1112

1213
func TestConfigEventMarshaling(t *testing.T) {
@@ -28,7 +29,7 @@ func TestConfigEventMarshaling(t *testing.T) {
2829
t.Errorf("could not marshal event. details: %v", err)
2930
}
3031

31-
test.AssertJsonsEqual(t, inputJSON, outputJSON)
32+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
3233
}
3334

3435
func TestConfigMarshalingMalformedJson(t *testing.T) {

events/connect_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/aws/aws-lambda-go/events/test"
10+
"github.com/stretchr/testify/assert"
1011
)
1112

1213
func TestConnectMarshaling(t *testing.T) {
@@ -27,7 +28,7 @@ func TestConnectMarshaling(t *testing.T) {
2728
}
2829

2930
// 4. check result
30-
test.AssertJsonsEqual(t, inputJson, outputJson)
31+
assert.JSONEq(t, string(inputJson), string(outputJson))
3132
}
3233

3334
func TestConnectMarshalingMalformedJson(t *testing.T) {

events/dynamodb_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"testing"
99

1010
"github.com/aws/aws-lambda-go/events/test"
11+
"github.com/stretchr/testify/assert"
1112
)
1213

1314
func TestDynamoDBEventMarshaling(t *testing.T) {
@@ -28,7 +29,7 @@ func TestDynamoDBEventMarshaling(t *testing.T) {
2829
}
2930

3031
// 4. check result
31-
test.AssertJsonsEqual(t, inputJson, outputJson)
32+
assert.JSONEq(t, string(inputJson), string(outputJson))
3233
}
3334

3435
func TestDynamoDBEventMarshalingMalformedJson(t *testing.T) {

events/firehose_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func testMarshaling(t *testing.T, jsonFile string) {
3737
}
3838

3939
// 4. check result
40-
test.AssertJsonsEqual(t, inputJson, outputJson)
40+
assert.JSONEq(t, string(inputJson), string(outputJson))
4141
}
4242

4343
func TestSampleTransformation(t *testing.T) {

0 commit comments

Comments
 (0)