Skip to content

Commit ed4dc4f

Browse files
authored
chore: bump min go to 1.20 and remove 95% of the go-cmp dependency (#499)
1 parent daa9e2b commit ed4dc4f

19 files changed

+132
-129
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "5974e1d2-ba43-4e1f-ba73-f9632f9b1063",
3+
"type": "feature",
4+
"description": "Bump minimum Go version to 1.20 per our language support policy.",
5+
"modules": [
6+
"."
7+
]
8+
}

.github/workflows/api_diff_check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Go 1.x
1717
uses: actions/setup-go@v2
1818
with:
19-
go-version: ^1.16
19+
go-version: "1.20"
2020
id: go
2121

2222
- name: Check out code into the Go module directory

.github/workflows/codegen.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ubuntu-latest]
16-
go-version: [1.19]
16+
go-version: ["1.20"]
1717
env:
1818
JAVA_TOOL_OPTIONS: "-Xmx2g"
1919
steps:

.github/workflows/go.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ubuntu-latest, macos-latest, windows-latest]
16-
go-version: ["1.19", "1.20", "1.21"]
16+
go-version: ["1.20", "1.21", "1.22"]
1717
steps:
1818
- uses: actions/checkout@v2
1919

auth/bearer/middleware_test.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ package bearer
22

33
import (
44
"context"
5-
"net/http"
65
"net/url"
6+
"reflect"
77
"strings"
88
"testing"
99

1010
smithyhttp "github.com/aws/smithy-go/transport/http"
11-
"github.com/google/go-cmp/cmp"
12-
"github.com/google/go-cmp/cmp/cmpopts"
1311
)
1412

1513
func TestSignHTTPSMessage(t *testing.T) {
@@ -65,13 +63,14 @@ func TestSignHTTPSMessage(t *testing.T) {
6563
t.Fatalf("expect no error, got %v", err)
6664
}
6765

68-
options := []cmp.Option{
69-
cmpopts.IgnoreUnexported(smithyhttp.Request{}),
70-
cmpopts.IgnoreUnexported(http.Request{}),
71-
}
66+
expect := c.expectMessage.(*smithyhttp.Request)
7267

73-
if diff := cmp.Diff(c.expectMessage, message, options...); diff != "" {
74-
t.Errorf("expect match\n%s", diff)
68+
actual, ok := message.(*smithyhttp.Request)
69+
if !ok {
70+
t.Fatalf("*smithyhttp.Request != %T", actual)
71+
}
72+
if !reflect.DeepEqual(expect.Header, actual.Header) {
73+
t.Errorf("%v != %v", expect.Header, actual.Header)
7574
}
7675
})
7776
}

auth/bearer/token_cache_test.go

+35-36
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"sync/atomic"
1010
"testing"
1111
"time"
12-
13-
"github.com/google/go-cmp/cmp"
1412
)
1513

1614
var _ TokenProvider = (*TokenCache)(nil)
@@ -33,17 +31,17 @@ func TestTokenCache_cache(t *testing.T) {
3331
if err != nil {
3432
t.Fatalf("expect no error, got %v", err)
3533
}
36-
if diff := cmp.Diff(expectToken, token); diff != "" {
37-
t.Errorf("expect token match\n%s", diff)
34+
if expectToken != token {
35+
t.Errorf("expect token match: %v != %v", expectToken, token)
3836
}
3937

4038
for i := 0; i < 100; i++ {
4139
token, err := provider.RetrieveBearerToken(context.Background())
4240
if err != nil {
4341
t.Fatalf("expect no error, got %v", err)
4442
}
45-
if diff := cmp.Diff(expectToken, token); diff != "" {
46-
t.Errorf("expect token match\n%s", diff)
43+
if expectToken != token {
44+
t.Errorf("expect token match: %v != %v", expectToken, token)
4745
}
4846
}
4947
}
@@ -66,8 +64,8 @@ func TestTokenCache_cacheConcurrent(t *testing.T) {
6664
if err != nil {
6765
t.Fatalf("expect no error, got %v", err)
6866
}
69-
if diff := cmp.Diff(expectToken, token); diff != "" {
70-
t.Errorf("expect token match\n%s", diff)
67+
if expectToken != token {
68+
t.Errorf("expect token match: %v != %v", expectToken, token)
7169
}
7270

7371
for i := 0; i < 100; i++ {
@@ -78,8 +76,8 @@ func TestTokenCache_cacheConcurrent(t *testing.T) {
7876
if err != nil {
7977
t.Fatalf("expect no error, got %v", err)
8078
}
81-
if diff := cmp.Diff(expectToken, token); diff != "" {
82-
t.Errorf("expect token match\n%s", diff)
79+
if expectToken != token {
80+
t.Errorf("expect token match: %v != %v", expectToken, token)
8381
}
8482
})
8583
}
@@ -115,8 +113,8 @@ func TestTokenCache_expired(t *testing.T) {
115113
if err != nil {
116114
t.Fatalf("expect no error, got %v", err)
117115
}
118-
if diff := cmp.Diff(expectToken, token); diff != "" {
119-
t.Errorf("expect token match\n%s", diff)
116+
if expectToken != token {
117+
t.Errorf("expect token match: %v != %v", expectToken, token)
120118
}
121119
}
122120
if e, a := 1, int(atomic.LoadInt32(retrievedCount)); e != a {
@@ -132,8 +130,8 @@ func TestTokenCache_expired(t *testing.T) {
132130
if err != nil {
133131
t.Fatalf("expect no error, got %v", err)
134132
}
135-
if diff := cmp.Diff(refreshedToken, token); diff != "" {
136-
t.Errorf("expect refreshed token match\n%s", diff)
133+
if refreshedToken != token {
134+
t.Errorf("expect refreshed token match: %v != %v", refreshedToken, token)
137135
}
138136
if e, a := 2, int(atomic.LoadInt32(retrievedCount)); e != a {
139137
t.Errorf("expect %v provider calls, got %v", e, a)
@@ -192,8 +190,9 @@ func TestTokenCache_cancelled(t *testing.T) {
192190
if err != nil {
193191
t.Errorf("expect no error, got %v", err)
194192
} else {
195-
if diff := cmp.Diff(Token{Value: "abc123"}, token); diff != "" {
196-
t.Errorf("expect token retrieve match\n%s", diff)
193+
expect := Token{Value: "abc123"}
194+
if expect != token {
195+
t.Errorf("expect token retrieve match: %v != %v", expect, token)
197196
}
198197
}
199198
}()
@@ -284,8 +283,8 @@ func TestTokenCache_asyncRefresh(t *testing.T) {
284283
if err != nil {
285284
t.Fatalf("expect no error, got %v", err)
286285
}
287-
if diff := cmp.Diff(expectToken, token); diff != "" {
288-
t.Errorf("expect token match\n%s", diff)
286+
if expectToken != token {
287+
t.Errorf("expect token match: %v != %v", expectToken, token)
289288
}
290289

291290
// 2-5: Offset time for subsequent calls to retrieve to trigger asynchronous
@@ -299,8 +298,8 @@ func TestTokenCache_asyncRefresh(t *testing.T) {
299298
if err != nil {
300299
t.Fatalf("expect no error, got %v", err)
301300
}
302-
if diff := cmp.Diff(expectToken, token); diff != "" {
303-
t.Errorf("expect token match\n%s", diff)
301+
if expectToken != token {
302+
t.Errorf("expect token match: %v != %v", expectToken, token)
304303
}
305304
}
306305
// Wait for all async refreshes to complete
@@ -317,8 +316,8 @@ func TestTokenCache_asyncRefresh(t *testing.T) {
317316
if err != nil {
318317
t.Fatalf("expect no error, got %v", err)
319318
}
320-
if diff := cmp.Diff(expectToken, token); diff != "" {
321-
t.Errorf("expect token match\n%s", diff)
319+
if expectToken != token {
320+
t.Errorf("expect token match: %v != %v", expectToken, token)
322321
}
323322
testWaitAsyncRefreshDone(provider)
324323
}
@@ -329,8 +328,8 @@ func TestTokenCache_asyncRefresh(t *testing.T) {
329328
if err != nil {
330329
t.Fatalf("expect no error, got %v", err)
331330
}
332-
if diff := cmp.Diff(refreshedToken, token); diff != "" {
333-
t.Errorf("expect refreshed token match\n%s", diff)
331+
if refreshedToken != token {
332+
t.Errorf("expect refreshed token match: %v != %v", refreshedToken, token)
334333
}
335334
}
336335

@@ -374,8 +373,8 @@ func TestTokenCache_asyncRefreshWithMinDelay(t *testing.T) {
374373
if err != nil {
375374
t.Fatalf("expect no error, got %v", err)
376375
}
377-
if diff := cmp.Diff(expectToken, token); diff != "" {
378-
t.Errorf("expect token match\n%s", diff)
376+
if expectToken != token {
377+
t.Errorf("expect token match: %v != %v", expectToken, token)
379378
}
380379

381380
// 2-5: Offset time for subsequent calls to retrieve to trigger asynchronous
@@ -389,8 +388,8 @@ func TestTokenCache_asyncRefreshWithMinDelay(t *testing.T) {
389388
if err != nil {
390389
t.Fatalf("expect no error, got %v", err)
391390
}
392-
if diff := cmp.Diff(expectToken, token); diff != "" {
393-
t.Errorf("expect token match\n%s", diff)
391+
if expectToken != token {
392+
t.Errorf("expect token match: %v != %v", expectToken, token)
394393
}
395394
// Wait for all async refreshes to complete ensure not deduped
396395
testWaitAsyncRefreshDone(provider)
@@ -411,8 +410,8 @@ func TestTokenCache_asyncRefreshWithMinDelay(t *testing.T) {
411410
if err != nil {
412411
t.Fatalf("expect no error, got %v", err)
413412
}
414-
if diff := cmp.Diff(expectToken, token); diff != "" {
415-
t.Errorf("expect token match\n%s", diff)
413+
if expectToken != token {
414+
t.Errorf("expect token match: %v != %v", expectToken, token)
416415
}
417416
// Wait for all async refreshes to complete ensure not deduped
418417
testWaitAsyncRefreshDone(provider)
@@ -423,8 +422,8 @@ func TestTokenCache_asyncRefreshWithMinDelay(t *testing.T) {
423422
if err != nil {
424423
t.Fatalf("expect no error, got %v", err)
425424
}
426-
if diff := cmp.Diff(refreshedToken, token); diff != "" {
427-
t.Errorf("expect refreshed token match\n%s", diff)
425+
if refreshedToken != token {
426+
t.Errorf("expect refreshed token match: %v != %v", refreshedToken, token)
428427
}
429428
}
430429

@@ -468,8 +467,8 @@ func TestTokenCache_disableAsyncRefresh(t *testing.T) {
468467
if err != nil {
469468
t.Fatalf("expect no error, got %v", err)
470469
}
471-
if diff := cmp.Diff(expectToken, token); diff != "" {
472-
t.Errorf("expect token match\n%s", diff)
470+
if expectToken != token {
471+
t.Errorf("expect token match: %v != %v", expectToken, token)
473472
}
474473

475474
// Update time into refresh window before token expires
@@ -499,8 +498,8 @@ func TestTokenCache_disableAsyncRefresh(t *testing.T) {
499498
if err != nil {
500499
t.Fatalf("expect no error, got %v", err)
501500
}
502-
if diff := cmp.Diff(refreshedToken, token); diff != "" {
503-
t.Errorf("expect refreshed token match\n%s", diff)
501+
if refreshedToken != token {
502+
t.Errorf("expect refreshed token match: %v != %v", refreshedToken, token)
504503
}
505504
}
506505

document/json/decoder_test.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package json_test
22

33
import (
44
"math/big"
5+
"reflect"
56
"testing"
67
"time"
78

89
"github.com/aws/smithy-go/document"
910
"github.com/aws/smithy-go/document/internal/serde"
1011
"github.com/aws/smithy-go/document/json"
11-
"github.com/google/go-cmp/cmp"
1212
)
1313

1414
var decodeArrayTestCases = map[string]testCase{
@@ -153,14 +153,11 @@ func testDecodeJSONInterface(t *testing.T, tt testCase) {
153153
if err := d.DecodeJSONInterface(MustJSONUnmarshal(tt.json, !tt.disableJSONNumber), tt.actual); (err != nil) != tt.wantErr {
154154
t.Errorf("DecodeJSONInterface() error = %v, wantErr %v", err, tt.wantErr)
155155
}
156-
if diff := cmp.Diff(
157-
serde.PtrToValue(tt.want),
158-
serde.PtrToValue(tt.actual),
159-
cmp.AllowUnexported(StructA{}, StructB{}),
160-
cmp.Comparer(cmpBigFloat()),
161-
cmp.Comparer(cmpBigInt()),
162-
); len(diff) > 0 {
163-
t.Error(diff)
156+
157+
expect := serde.PtrToValue(tt.want)
158+
actual := serde.PtrToValue(tt.actual)
159+
if !reflect.DeepEqual(expect, actual) {
160+
t.Errorf("%v != %v", expect, actual)
164161
}
165162
}
166163

document/json/encoder_test.go

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package json_test
22

33
import (
4-
"github.com/aws/smithy-go/document"
5-
"github.com/aws/smithy-go/document/internal/serde"
6-
"github.com/aws/smithy-go/document/json"
7-
"github.com/google/go-cmp/cmp"
4+
"reflect"
85
"testing"
96
"time"
7+
8+
"github.com/aws/smithy-go/document"
9+
"github.com/aws/smithy-go/document/json"
1010
)
1111

1212
func TestEncoder_Encode(t *testing.T) {
@@ -79,15 +79,10 @@ func testEncode(t *testing.T, tt testCase) {
7979
t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr)
8080
}
8181

82+
expect := MustJSONUnmarshal(tt.json, !tt.disableJSONNumber)
8283
got := MustJSONUnmarshal(encodeBytes, !tt.disableJSONNumber)
8384

84-
if diff := cmp.Diff(
85-
serde.PtrToValue(MustJSONUnmarshal(tt.json, !tt.disableJSONNumber)),
86-
serde.PtrToValue(got),
87-
cmp.AllowUnexported(StructA{}, StructB{}),
88-
cmp.Comparer(cmpBigFloat()),
89-
cmp.Comparer(cmpBigInt()),
90-
); len(diff) > 0 {
91-
t.Error(diff)
85+
if !reflect.DeepEqual(expect, got) {
86+
t.Errorf("%v != %v", expect, got)
9287
}
9388
}

document/json/shared_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,9 @@ var sharedNumberTestCases = map[string]testCase{
426426
return &x
427427
}(),
428428
want: func() *big.Float {
429-
return big.NewFloat(math.MaxFloat64)
429+
// this is slightly different than big.NewFloat(math.MaxFloat64)
430+
x, _ := (&big.Float{}).SetString(strconv.FormatFloat(math.MaxFloat64, 'e', -1, 64))
431+
return x
430432
}(),
431433
},
432434
"float64 to big.Float": {

0 commit comments

Comments
 (0)