Skip to content

Commit

Permalink
dep: remove go-cmp usage from internal/ (#2534)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucix-aws committed Mar 6, 2024
1 parent 3af08d7 commit 437a3af
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 36 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module github.com/aws/aws-sdk-go-v2

require (
github.com/aws/smithy-go v1.20.1
github.com/google/go-cmp v0.5.8
github.com/jmespath/go-jmespath v0.4.0
)

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw=
github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
Expand Down
1 change: 0 additions & 1 deletion internal/configsources/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw=
github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
12 changes: 10 additions & 2 deletions internal/endpoints/awsrulesfn/arn_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package awsrulesfn

import (
"github.com/google/go-cmp/cmp"
"fmt"
"reflect"
"testing"
)

Expand Down Expand Up @@ -72,9 +73,16 @@ func TestParseARN(t *testing.T) {
for _, c := range cases {
t.Run(c.input, func(t *testing.T) {
actual := ParseARN(c.input)
if diff := cmp.Diff(c.expect, actual); diff != "" {
if diff := cmpDiff(c.expect, actual); diff != "" {
t.Errorf("expect ARN match\n%s", diff)
}
})
}
}

func cmpDiff(e, a interface{}) string {
if !reflect.DeepEqual(e, a) {
return fmt.Sprintf("%v != %v", e, a)
}
return ""
}
1 change: 0 additions & 1 deletion internal/endpoints/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.20
require (
github.com/aws/aws-sdk-go-v2 v1.25.2
github.com/aws/smithy-go v1.20.1
github.com/google/go-cmp v0.5.8
)

replace github.com/aws/aws-sdk-go-v2 => ../../../
2 changes: 0 additions & 2 deletions internal/endpoints/v2/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw=
github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
25 changes: 17 additions & 8 deletions internal/endpoints/v2/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package endpoints_test

import (
"bytes"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/endpoints/v2"
"github.com/aws/smithy-go/logging"
"github.com/google/go-cmp/cmp"
"fmt"
"log"
"reflect"
"regexp"
"strconv"
"testing"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/endpoints/v2"
"github.com/aws/smithy-go/logging"
)

type testCase struct {
Expand Down Expand Up @@ -1172,7 +1174,7 @@ func TestResolveEndpoint(t *testing.T) {
if (err != nil) != (tt.WantErr) {
t.Errorf("WantErr=%v, got error: %v", tt.WantErr, err)
}
if diff := cmp.Diff(tt.Expected, endpoint); len(diff) > 0 {
if diff := cmpDiff(tt.Expected, endpoint); len(diff) > 0 {
t.Error(diff)
}
})
Expand Down Expand Up @@ -1300,7 +1302,7 @@ func TestLogDeprecated(t *testing.T) {
return &logging.StandardLogger{
Logger: log.New(buffer, "", 0),
}, func(t *testing.T) {
if diff := cmp.Diff("WARN endpoint identifier \"bar\", url \"https://foo.bar.bar.tld\" marked as deprecated\n", buffer.String()); len(diff) > 0 {
if diff := cmpDiff("WARN endpoint identifier \"bar\", url \"https://foo.bar.bar.tld\" marked as deprecated\n", buffer.String()); len(diff) > 0 {
t.Errorf(diff)
}
}
Expand All @@ -1323,7 +1325,7 @@ func TestLogDeprecated(t *testing.T) {
return &logging.StandardLogger{
Logger: log.New(buffer, "", 0),
}, func(t *testing.T) {
if diff := cmp.Diff("WARN endpoint identifier \"bar\", url \"https://foo-fips.bar.bar.tld\" marked as deprecated\n", buffer.String()); len(diff) > 0 {
if diff := cmpDiff("WARN endpoint identifier \"bar\", url \"https://foo-fips.bar.bar.tld\" marked as deprecated\n", buffer.String()); len(diff) > 0 {
t.Errorf(diff)
}
}
Expand All @@ -1349,7 +1351,7 @@ func TestLogDeprecated(t *testing.T) {
t.Errorf("WantErr(%v), got error %v", tt.WantErr, err)
}

if diff := cmp.Diff(tt.Expected, endpoint); len(diff) > 0 {
if diff := cmpDiff(tt.Expected, endpoint); len(diff) > 0 {
t.Errorf(diff)
}

Expand All @@ -1359,3 +1361,10 @@ func TestLogDeprecated(t *testing.T) {
})
}
}

func cmpDiff(e, a interface{}) string {
if !reflect.DeepEqual(e, a) {
return fmt.Sprintf("%v != %v", e, a)
}
return ""
}
1 change: 0 additions & 1 deletion internal/protocoltest/awsrestjson/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw=
github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
1 change: 0 additions & 1 deletion internal/protocoltest/ec2query/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw=
github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
1 change: 0 additions & 1 deletion internal/protocoltest/jsonrpc/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw=
github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
1 change: 0 additions & 1 deletion internal/protocoltest/jsonrpc10/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw=
github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
1 change: 0 additions & 1 deletion internal/protocoltest/query/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw=
github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
1 change: 0 additions & 1 deletion internal/protocoltest/restxml/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw=
github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
1 change: 0 additions & 1 deletion internal/protocoltest/restxmlwithnamespace/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw=
github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
1 change: 0 additions & 1 deletion internal/v4a/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.20
require (
github.com/aws/aws-sdk-go-v2 v1.25.2
github.com/aws/smithy-go v1.20.1
github.com/google/go-cmp v0.5.8
)

replace github.com/aws/aws-sdk-go-v2 => ../../
2 changes: 0 additions & 2 deletions internal/v4a/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw=
github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
5 changes: 2 additions & 3 deletions internal/v4a/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/aws/smithy-go/logging"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
"github.com/google/go-cmp/cmp"
)

type stubCredentialsProviderFunc func(context.Context) (Credentials, error)
Expand Down Expand Up @@ -85,7 +84,7 @@ func TestSignHTTPRequestMiddleware(t *testing.T) {
}

expectCreds, _ := tt.creds.RetrievePrivateKey(ctx)
if diff := cmp.Diff(expectCreds, credentials); len(diff) > 0 {
if diff := cmpDiff(expectCreds, credentials); len(diff) > 0 {
t.Error(diff)
}
if e, a := tt.hash, payloadHash; e != a {
Expand All @@ -94,7 +93,7 @@ func TestSignHTTPRequestMiddleware(t *testing.T) {
if e, a := signingName, service; e != a {
t.Errorf("expected %v, got %v", e, a)
}
if diff := cmp.Diff([]string{signingRegion}, regionSet); len(diff) > 0 {
if diff := cmpDiff([]string{signingRegion}, regionSet); len(diff) > 0 {
t.Error(diff)
}
return nil
Expand Down
7 changes: 3 additions & 4 deletions internal/v4a/presign_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/aws/smithy-go/logging"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
"github.com/google/go-cmp/cmp"
)

type httpPresignerFunc func(
Expand Down Expand Up @@ -145,7 +144,7 @@ func TestPresignHTTPRequestMiddleware(t *testing.T) {
}

expectCreds, _ := tt.Creds.RetrievePrivateKey(context.Background())
if diff := cmp.Diff(expectCreds, credentials); len(diff) > 0 {
if diff := cmpDiff(expectCreds, credentials); len(diff) > 0 {
t.Error(diff)
}
if e, a := tt.PayloadHash, payloadHash; e != a {
Expand All @@ -154,7 +153,7 @@ func TestPresignHTTPRequestMiddleware(t *testing.T) {
if e, a := signingName, service; e != a {
t.Errorf("expected %v, got %v", e, a)
}
if diff := cmp.Diff([]string{signingRegion}, regionSet); len(diff) > 0 {
if diff := cmpDiff([]string{signingRegion}, regionSet); len(diff) > 0 {
t.Error(diff)
}

Expand Down Expand Up @@ -201,7 +200,7 @@ func TestPresignHTTPRequestMiddleware(t *testing.T) {
t.Fatalf("expect no error, got %v", err)
}

if diff := cmp.Diff(tt.ExpectResult, result.Result); len(diff) != 0 {
if diff := cmpDiff(tt.ExpectResult, result.Result); len(diff) != 0 {
t.Errorf("expect result match\n%v", diff)
}

Expand Down
11 changes: 9 additions & 2 deletions internal/v4a/v4a_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math/big"
"net/http"
"net/url"
"reflect"
"strconv"
"strings"
"testing"
Expand All @@ -15,7 +16,6 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/v4a/internal/crypto"
"github.com/aws/smithy-go/logging"
"github.com/google/go-cmp/cmp"
)

const (
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestSign_buildCanonicalHeaders(t *testing.T) {
`fooinnerspace;fooleadingspace;foomultiplespace;foonospace;footabspace;footrailingspace;foowrappedspace;host;x-amz-date;x-amz-region-set`,
``,
}, "\n")
if diff := cmp.Diff(expectCanonicalString, build.CanonicalString); diff != "" {
if diff := cmpDiff(expectCanonicalString, build.CanonicalString); diff != "" {
t.Errorf("expect match, got\n%s", diff)
}
}
Expand Down Expand Up @@ -420,3 +420,10 @@ func (s staticCredentialsProvider) Retrieve(_ context.Context) (aws.Credentials,

return v, nil
}

func cmpDiff(e, a interface{}) string {
if !reflect.DeepEqual(e, a) {
return fmt.Sprintf("%v != %v", e, a)
}
return ""
}

0 comments on commit 437a3af

Please sign in to comment.