Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dep: drop go-cmp dependency #2538

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
400 changes: 400 additions & 0 deletions .changelog/0eccc8b40f4e454e951f4cad2421c237.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions .changelog/4e551f8f59a14f7c8c9d7e2daf5b22f3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "4e551f8f-59a1-4f7c-8c9d-7e2daf5b22f3",
"type": "bugfix",
"description": "Remove dependency on go-cmp.",
"modules": [
"."
]
}
13 changes: 10 additions & 3 deletions aws/credential_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math/rand"
"reflect"
"strings"
"sync"
"sync/atomic"
Expand All @@ -12,7 +13,6 @@ import (

sdkrand "github.com/aws/aws-sdk-go-v2/internal/rand"
"github.com/aws/aws-sdk-go-v2/internal/sdk"
"github.com/google/go-cmp/cmp"
)

type stubCredentialsProvider struct {
Expand Down Expand Up @@ -543,7 +543,7 @@ func TestCredentialsCache_cacheStrategies(t *testing.T) {
// Truncate expires time so its easy to compare
creds.Expires = creds.Expires.Truncate(time.Second)

if diff := cmp.Diff(c.expectCreds, creds); diff != "" {
if diff := cmpDiff(c.expectCreds, creds); diff != "" {
t.Errorf("expect creds match\n%s", diff)
}
})
Expand Down Expand Up @@ -611,7 +611,7 @@ func (m mockAdjustExpiryBy) AdjustExpiresBy(creds Credentials, dur time.Duration
Credentials, error,
) {
if m.expectInputCreds.HasKeys() {
if diff := cmp.Diff(m.expectInputCreds, creds); diff != "" {
if diff := cmpDiff(m.expectInputCreds, creds); diff != "" {
return Credentials{}, fmt.Errorf("expect creds match\n%s", diff)
}
}
Expand Down Expand Up @@ -660,3 +660,10 @@ func TestCredentialsCache_IsCredentialsProvider(t *testing.T) {
}

var _ isCredentialsProvider = (*CredentialsCache)(nil)

func cmpDiff(e, a interface{}) string {
if !reflect.DeepEqual(e, a) {
return fmt.Sprintf("%v != %v", e, a)
}
return ""
}
13 changes: 10 additions & 3 deletions aws/defaults/defaults_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package defaults

import (
"fmt"
"reflect"
"strconv"
"testing"
"time"

"github.com/aws/aws-sdk-go-v2/aws"

"github.com/google/go-cmp/cmp"
)

func TestConfigV1(t *testing.T) {
Expand Down Expand Up @@ -55,9 +55,16 @@ func TestConfigV1(t *testing.T) {
if err != nil {
t.Fatalf("expect no error, got %v", err)
}
if diff := cmp.Diff(tt.Expected, got); len(diff) > 0 {
if diff := cmpDiff(tt.Expected, got); len(diff) > 0 {
t.Error(diff)
}
})
}
}

func cmpDiff(e, a interface{}) string {
if !reflect.DeepEqual(e, a) {
return fmt.Sprintf("%v != %v", e, a)
}
return ""
}
17 changes: 12 additions & 5 deletions aws/middleware/user_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package middleware

import (
"context"
"fmt"
"net/http"
"os"
"reflect"
"runtime"
"strings"
"testing"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)

var expectedAgent = aws.SDKName + "/" + aws.SDKVersion + " os/" + getNormalizedOSName() + " lang/go#" + languageVersion + " md/GOOS#" + runtime.GOOS + " md/GOARCH#" + runtime.GOARCH
Expand All @@ -37,7 +37,7 @@ func TestRequestUserAgent_HandleBuild(t *testing.T) {
}},
Next: func(t *testing.T, expect middleware.BuildInput) middleware.BuildHandler {
return middleware.BuildHandlerFunc(func(ctx context.Context, input middleware.BuildInput) (o middleware.BuildOutput, m middleware.Metadata, err error) {
if diff := cmp.Diff(input, expect, cmpopts.IgnoreUnexported(http.Request{}, smithyhttp.Request{})); len(diff) > 0 {
if diff := cmpDiff(input, expect); len(diff) > 0 {
t.Error(diff)
}
return o, m, err
Expand All @@ -59,7 +59,7 @@ func TestRequestUserAgent_HandleBuild(t *testing.T) {
}},
Next: func(t *testing.T, expect middleware.BuildInput) middleware.BuildHandler {
return middleware.BuildHandlerFunc(func(ctx context.Context, input middleware.BuildInput) (o middleware.BuildOutput, m middleware.Metadata, err error) {
if diff := cmp.Diff(input, expect, cmpopts.IgnoreUnexported(http.Request{}, smithyhttp.Request{})); len(diff) > 0 {
if diff := cmpDiff(input, expect); len(diff) > 0 {
t.Error(diff)
}
return o, m, err
Expand All @@ -81,7 +81,7 @@ func TestRequestUserAgent_HandleBuild(t *testing.T) {
}},
Next: func(t *testing.T, expect middleware.BuildInput) middleware.BuildHandler {
return middleware.BuildHandlerFunc(func(ctx context.Context, input middleware.BuildInput) (o middleware.BuildOutput, m middleware.Metadata, err error) {
if diff := cmp.Diff(input, expect, cmpopts.IgnoreUnexported(http.Request{}, smithyhttp.Request{})); len(diff) > 0 {
if diff := cmpDiff(input, expect); len(diff) > 0 {
t.Error(diff)
}
return o, m, err
Expand Down Expand Up @@ -436,3 +436,10 @@ func TestAddUserAgentKeyValue_AddToStack(t *testing.T) {
})
}
}

func cmpDiff(e, a interface{}) string {
if !reflect.DeepEqual(e, a) {
return fmt.Sprintf("%v != %v", e, a)
}
return ""
}
10 changes: 8 additions & 2 deletions aws/retry/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/aws/aws-sdk-go-v2/internal/sdk"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
"github.com/google/go-cmp/cmp"
)

func TestMetricsHeaderMiddleware(t *testing.T) {
Expand Down Expand Up @@ -427,7 +426,7 @@ func TestAttemptMiddleware(t *testing.T) {
t.Errorf("expect %v, got %v", tt.Err, err)
}
}
if diff := cmp.Diff(recorded, tt.Expect); len(diff) > 0 {
if diff := cmpDiff(recorded, tt.Expect); len(diff) > 0 {
t.Error(diff)
}

Expand Down Expand Up @@ -493,3 +492,10 @@ type mockRawResponseKey struct{}
func setMockRawResponse(m *middleware.Metadata, v interface{}) {
m.Set(mockRawResponseKey{}, v)
}

func cmpDiff(e, a interface{}) string {
if !reflect.DeepEqual(e, a) {
return fmt.Sprintf("%v != %v", e, a)
}
return ""
}
3 changes: 1 addition & 2 deletions aws/signer/v4/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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"
)

func TestComputePayloadHashMiddleware(t *testing.T) {
Expand Down Expand Up @@ -303,7 +302,7 @@ func TestSwapComputePayloadSHA256ForUnsignedPayloadMiddleware(t *testing.T) {
t.Fatalf("expect no error, got %v", err)
}

if diff := cmp.Diff(c.ExpectIDs, stack.Finalize.List()); len(diff) != 0 {
if diff := cmpDiff(c.ExpectIDs, stack.Finalize.List()); len(diff) != 0 {
t.Errorf("expect match\n%v", diff)
}
})
Expand Down
3 changes: 1 addition & 2 deletions aws/signer/v4/presign_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 httpPresignerFunc func(
Expand Down Expand Up @@ -202,7 +201,7 @@ func TestPresignHTTPRequestMiddleware(t *testing.T) {
t.Fatalf("expect no error, got %v", err)
}

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

Expand Down
11 changes: 9 additions & 2 deletions aws/signer/v4/v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"io/ioutil"
"net/http"
"net/url"
"reflect"
"strings"
"testing"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
v4Internal "github.com/aws/aws-sdk-go-v2/aws/signer/internal/v4"
"github.com/google/go-cmp/cmp"
)

var testCredentials = aws.Credentials{AccessKeyID: "AKID", SecretAccessKey: "SECRET", SessionToken: "SESSION"}
Expand Down Expand Up @@ -329,7 +329,7 @@ func TestSign_buildCanonicalHeaders(t *testing.T) {
`fooinnerspace;fooleadingspace;foomultiplespace;foonospace;footabspace;footrailingspace;foowrappedspace;host;x-amz-date`,
``,
}, "\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 All @@ -354,3 +354,10 @@ func BenchmarkSignRequest(b *testing.B) {
signer.SignHTTP(context.Background(), testCredentials, req, bodyHash, "dynamodb", "us-east-1", time.Now())
}
}

func cmpDiff(e, a interface{}) string {
if !reflect.DeepEqual(e, a) {
return fmt.Sprintf("%v != %v", e, a)
}
return ""
}
15 changes: 11 additions & 4 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"
"fmt"
"os"
"reflect"
"testing"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/google/go-cmp/cmp"
)

func TestConfigs_SharedConfigOptions(t *testing.T) {
Expand Down Expand Up @@ -47,7 +47,7 @@ func TestConfigs_SharedConfigOptions(t *testing.T) {
if e, a := "profile-name", profile; e != a {
t.Errorf("expect %v profile, got %v", e, a)
}
if diff := cmp.Diff([]string{"creds-file"}, files); len(diff) != 0 {
if diff := cmpDiff([]string{"creds-file"}, files); len(diff) != 0 {
t.Errorf("expect resolved shared config match, got diff: \n %s", diff)
}

Expand Down Expand Up @@ -85,7 +85,7 @@ func TestConfigs_AppendFromLoaders(t *testing.T) {
t.Errorf("expect %v configs, got %v", e, a)
}

if diff := cmp.Diff(options, cfgs[0]); len(diff) != 0 {
if diff := cmpDiff(options, cfgs[0]); len(diff) != 0 {
t.Errorf("expect config match, got diff: \n %s", diff)
}
}
Expand Down Expand Up @@ -133,7 +133,7 @@ func TestConfigs_ResolveAWSConfig(t *testing.T) {
expectedSources = append(expectedSources, s)
}

if diff := cmp.Diff(expectedSources, cfg.ConfigSources); len(diff) != 0 {
if diff := cmpDiff(expectedSources, cfg.ConfigSources); len(diff) != 0 {
t.Errorf("expect config sources match, got diff: \n %s", diff)
}
}
Expand Down Expand Up @@ -210,3 +210,10 @@ func generateProfiles(n int) (string, error) {

return f.Name(), nil
}

func cmpDiff(e, a interface{}) string {
if !reflect.DeepEqual(e, a) {
return fmt.Sprintf("%v != %v", e, a)
}
return ""
}
3 changes: 1 addition & 2 deletions config/env_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
"github.com/aws/aws-sdk-go-v2/internal/awstesting"
"github.com/aws/smithy-go/ptr"
"github.com/google/go-cmp/cmp"
)

var _ sharedConfigProfileProvider = (*EnvConfig)(nil)
Expand Down Expand Up @@ -512,7 +511,7 @@ func TestNewEnvConfig(t *testing.T) {
t.Fatalf("WantErr=%v, got err=%v", c.WantErr, err)
}

if diff := cmp.Diff(c.Config, cfg); len(diff) > 0 {
if diff := cmpDiff(c.Config, cfg); len(diff) > 0 {
t.Errorf("expect config to match.\n%s",
diff)
}
Expand Down
1 change: 0 additions & 1 deletion config/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ require (
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.1
github.com/aws/aws-sdk-go-v2/service/sts v1.28.3
github.com/aws/smithy-go v1.20.1
github.com/google/go-cmp v0.5.8
)

require (
Expand Down
2 changes: 0 additions & 2 deletions config/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 config/resolve_bearer_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/aws/aws-sdk-go-v2/credentials/ssocreds"
"github.com/aws/aws-sdk-go-v2/internal/sdk"
smithybearer "github.com/aws/smithy-go/auth/bearer"
"github.com/google/go-cmp/cmp"
)

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

if diff := cmp.Diff(c.expectToken, token); diff != "" {
if diff := cmpDiff(c.expectToken, token); diff != "" {
t.Errorf("expect token match\n%s", diff)
}
})
Expand Down Expand Up @@ -168,7 +167,7 @@ func TestWrapWithBearerAuthTokenProvider(t *testing.T) {
t.Fatalf("expect no error, got %v", err)
}

if diff := cmp.Diff(c.expectToken, token); diff != "" {
if diff := cmpDiff(c.expectToken, token); diff != "" {
t.Errorf("expect token match\n%s", diff)
}
})
Expand Down
5 changes: 2 additions & 3 deletions config/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/aws/aws-sdk-go-v2/internal/awstesting"
"github.com/aws/aws-sdk-go-v2/internal/awstesting/unit"
"github.com/aws/smithy-go/logging"
"github.com/google/go-cmp/cmp"
)

func TestResolveCustomCABundle(t *testing.T) {
Expand Down Expand Up @@ -474,11 +473,11 @@ func TestResolveDefaultsMode(t *testing.T) {
t.Errorf("expect no error, got %v", err)
}

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

if diff := cmp.Diff(tt.ExpectedRuntimeEnvironment, cfg.RuntimeEnvironment); len(diff) > 0 {
if diff := cmpDiff(tt.ExpectedRuntimeEnvironment, cfg.RuntimeEnvironment); len(diff) > 0 {
t.Errorf(diff)
}
})
Expand Down