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 everywhere else #2537

Merged
merged 5 commits into from
Mar 6, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 0 additions & 1 deletion config/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
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
7 changes: 3 additions & 4 deletions config/shared_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/aws/aws-sdk-go-v2/internal/ini"
"github.com/aws/smithy-go/logging"
"github.com/aws/smithy-go/ptr"
"github.com/google/go-cmp/cmp"
)

var _ regionProvider = (*SharedConfig)(nil)
Expand Down Expand Up @@ -754,7 +753,7 @@ func TestNewSharedConfig(t *testing.T) {
if c.Err != nil {
t.Errorf("expect error: %v, got none", c.Err)
}
if diff := cmp.Diff(c.Expected, cfg); len(diff) > 0 {
if diff := cmpDiff(c.Expected, cfg); len(diff) > 0 {
t.Error(diff)
}
})
Expand Down Expand Up @@ -895,7 +894,7 @@ func TestLoadSharedConfigFromSection(t *testing.T) {
t.Fatalf("expect no error, got %v", err)
}

if diff := cmp.Diff(c.Expected, cfg); diff != "" {
if diff := cmpDiff(c.Expected, cfg); diff != "" {
t.Errorf("expect shared config match\n%s", diff)
}
})
Expand Down Expand Up @@ -1499,7 +1498,7 @@ func TestSharedConfigLoading(t *testing.T) {
t.Fatalf("expect no error, got %v", err)
}

if diff := cmp.Diff(c.Expect, cfg); diff != "" {
if diff := cmpDiff(c.Expect, cfg); diff != "" {
t.Errorf("expect shared config match\n%s", diff)
}
})
Expand Down
13 changes: 10 additions & 3 deletions credentials/ec2rolecreds/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"io/ioutil"
"reflect"
"strings"
"testing"
"time"
Expand All @@ -18,7 +19,6 @@ import (
"github.com/aws/smithy-go"
"github.com/aws/smithy-go/logging"
"github.com/aws/smithy-go/middleware"
"github.com/google/go-cmp/cmp"
)

const credsRespTmpl = `{
Expand Down Expand Up @@ -298,7 +298,7 @@ func TestProvider_HandleFailToRetrieve(t *testing.T) {
// Truncate time so it can be easily compared.
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 @@ -359,9 +359,16 @@ func TestProvider_AdjustExpiresBy(t *testing.T) {
t.Fatalf("expect no error, got %v", err)
}

if diff := cmp.Diff(c.expectCreds, creds); diff != "" {
if diff := cmpDiff(c.expectCreds, creds); diff != "" {
t.Errorf("expect creds 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 credentials/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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
1 change: 0 additions & 1 deletion credentials/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
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=
9 changes: 2 additions & 7 deletions credentials/ssocreds/sso_cached_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ import (
"time"

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

var tokenCmpOptions = cmp.Options{
cmp.AllowUnexported(token{}, tokenKnownFields{}, rfc3339{}),
}

func TestStandardSSOCacheTokenFilepath(t *testing.T) {
origHomeDur := osUserHomeDur
defer func() {
Expand Down Expand Up @@ -125,7 +120,7 @@ func TestLoadCachedToken(t *testing.T) {
t.Fatalf("expect no error, got %v", err)
}

if diff := cmp.Diff(c.expectToken, actualToken, tokenCmpOptions...); diff != "" {
if diff := cmpDiff(c.expectToken, actualToken); diff != "" {
t.Errorf("expect tokens match\n%s", diff)
}
})
Expand Down Expand Up @@ -181,7 +176,7 @@ func TestStoreCachedToken(t *testing.T) {
t.Fatalf("failed to load stored token, %v", err)
}

if diff := cmp.Diff(c.token, actual, tokenCmpOptions...); diff != "" {
if diff := cmpDiff(c.token, actual); diff != "" {
t.Errorf("expect tokens match\n%s", diff)
}
})
Expand Down
9 changes: 4 additions & 5 deletions credentials/ssocreds/sso_credentials_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/aws/aws-sdk-go-v2/internal/sdk"
"github.com/aws/aws-sdk-go-v2/service/sso"
"github.com/aws/aws-sdk-go-v2/service/sso/types"
"github.com/google/go-cmp/cmp"
)

type mockClient struct {
Expand All @@ -32,19 +31,19 @@ func (m mockClient) GetRoleCredentials(ctx context.Context, params *sso.GetRoleC
m.t.Helper()

if len(m.ExpectedAccountID) > 0 {
if diff := cmp.Diff(m.ExpectedAccountID, aws.ToString(params.AccountId)); len(diff) > 0 {
if diff := cmpDiff(m.ExpectedAccountID, aws.ToString(params.AccountId)); len(diff) > 0 {
m.t.Error(diff)
}
}

if len(m.ExpectedAccessToken) > 0 {
if diff := cmp.Diff(m.ExpectedAccessToken, aws.ToString(params.AccessToken)); len(diff) > 0 {
if diff := cmpDiff(m.ExpectedAccessToken, aws.ToString(params.AccessToken)); len(diff) > 0 {
m.t.Error(diff)
}
}

if len(m.ExpectedRoleName) > 0 {
if diff := cmp.Diff(m.ExpectedRoleName, aws.ToString(params.RoleName)); len(diff) > 0 {
if diff := cmpDiff(m.ExpectedRoleName, aws.ToString(params.RoleName)); len(diff) > 0 {
m.t.Error(diff)
}
}
Expand Down Expand Up @@ -187,7 +186,7 @@ func TestProvider(t *testing.T) {
t.Fatalf("expect no error, got %v", err)
}

if diff := cmp.Diff(tt.ExpectedCredentials, credentials); len(diff) > 0 {
if diff := cmpDiff(tt.ExpectedCredentials, credentials); len(diff) > 0 {
t.Errorf(diff)
}
})
Expand Down
21 changes: 12 additions & 9 deletions credentials/ssocreds/sso_token_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
"time"
Expand All @@ -17,8 +18,6 @@ import (
"github.com/aws/aws-sdk-go-v2/internal/sdk"
"github.com/aws/aws-sdk-go-v2/service/ssooidc"
smithybearer "github.com/aws/smithy-go/auth/bearer"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)

func TestSSOTokenProvider(t *testing.T) {
Expand Down Expand Up @@ -110,7 +109,7 @@ func TestSSOTokenProvider(t *testing.T) {
},
}

if diff := cmp.Diff(expect, actual, tokenCmpOptions...); diff != "" {
if diff := cmpDiff(expect, actual); diff != "" {
return fmt.Errorf("expect token file match\n%s", diff)
}
return nil
Expand Down Expand Up @@ -160,7 +159,7 @@ func TestSSOTokenProvider(t *testing.T) {
},
}

if diff := cmp.Diff(expect, actual, tokenCmpOptions...); diff != "" {
if diff := cmpDiff(expect, actual); diff != "" {
return fmt.Errorf("expect token file match\n%s", diff)
}
return nil
Expand Down Expand Up @@ -196,7 +195,7 @@ func TestSSOTokenProvider(t *testing.T) {
t.Fatalf("expect no error, got %v", err)
}

if diff := cmp.Diff(c.expectToken, token, tokenCmpOptions...); diff != "" {
if diff := cmpDiff(c.expectToken, token); diff != "" {
t.Errorf("expect token match\n%s", diff)
}

Expand All @@ -220,13 +219,17 @@ func (c *mockCreateTokenAPIClient) CreateToken(
*ssooidc.CreateTokenOutput, error,
) {
if c.expectInput != nil {
opts := cmp.Options{
cmpopts.IgnoreUnexported(ssooidc.CreateTokenInput{}),
}
if diff := cmp.Diff(c.expectInput, input, opts...); diff != "" {
if diff := cmpDiff(c.expectInput, input); diff != "" {
return nil, fmt.Errorf("expect input match\n%s", diff)
}
}

return c.output, c.err
}

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 modman.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
[dependencies]
"github.com/aws/aws-sdk-go" = "v1.44.28"
"github.com/aws/smithy-go" = "v1.20.1"
"github.com/google/go-cmp" = "v0.5.8"
"github.com/jmespath/go-jmespath" = "v0.4.0"
"golang.org/x/net" = "v0.19.0"

Expand Down
1 change: 0 additions & 1 deletion service/docdb/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +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/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 service/ec2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +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/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 service/internal/benchmark/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,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/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
Loading
Loading