Skip to content

Commit

Permalink
Fix improper use of Printf-style functions (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
djedward authored Dec 18, 2024
1 parent 858298a commit 885de40
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 24 deletions.
15 changes: 15 additions & 0 deletions .changelog/96979b8ab9d04d28990dfe28ae1aca84.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"id": "96979b8a-b9d0-4d28-990d-fe28ae1aca84",
"type": "bugfix",
"collapse": true,
"description": "Fix improper use of printf-style functions.",
"modules": [
".",
"config",
"credentials",
"feature/s3/manager",
"internal/endpoints/v2",
"service/kinesis/internal/testing",
"service/transcribestreaming/internal/testing"
]
}
4 changes: 2 additions & 2 deletions config/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,11 @@ func TestResolveDefaultsMode(t *testing.T) {
}

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

if diff := cmpDiff(tt.ExpectedRuntimeEnvironment, cfg.RuntimeEnvironment); len(diff) > 0 {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion credentials/ssocreds/sso_credentials_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func TestProvider(t *testing.T) {
}

if diff := cmpDiff(tt.ExpectedCredentials, credentials); len(diff) > 0 {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions feature/s3/manager/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package manager
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"net/http"
"sort"
"sync"

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

"github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
internalcontext "github.com/aws/aws-sdk-go-v2/internal/context"
Expand Down Expand Up @@ -686,7 +686,7 @@ func (u *multiuploader) shouldContinue(part int32, nextChunkLen int, err error)
msg = fmt.Sprintf("exceeded total allowed S3 limit MaxUploadParts (%d). Adjust PartSize to fit in this limit",
MaxUploadParts)
}
return false, fmt.Errorf(msg)
return false, errors.New(msg)
}

return true, err
Expand Down
16 changes: 8 additions & 8 deletions internal/awstesting/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func AssertURL(t *testing.T, expect, actual string, msgAndArgs ...interface{}) b

expectURL, err := url.Parse(expect)
if err != nil {
t.Errorf(errMsg("unable to parse expected URL", err, msgAndArgs))
t.Error(errMsg("unable to parse expected URL", err, msgAndArgs))
return false
}
actualURL, err := url.Parse(actual)
if err != nil {
t.Errorf(errMsg("unable to parse actual URL", err, msgAndArgs))
t.Error(errMsg("unable to parse actual URL", err, msgAndArgs))
return false
}

Expand All @@ -52,12 +52,12 @@ func AssertQuery(t *testing.T, expect, actual string, msgAndArgs ...interface{})

expectQ, err := url.ParseQuery(expect)
if err != nil {
t.Errorf(errMsg("unable to parse expected Query", err, msgAndArgs))
t.Error(errMsg("unable to parse expected Query", err, msgAndArgs))
return false
}
actualQ, err := url.ParseQuery(actual)
if err != nil {
t.Errorf(errMsg("unable to parse actual Query", err, msgAndArgs))
t.Error(errMsg("unable to parse actual Query", err, msgAndArgs))
return false
}

Expand Down Expand Up @@ -106,13 +106,13 @@ func AssertJSON(t *testing.T, expect, actual string, msgAndArgs ...interface{})

expectVal := map[string]interface{}{}
if err := json.Unmarshal([]byte(expect), &expectVal); err != nil {
t.Errorf(errMsg("unable to parse expected JSON", err, msgAndArgs...))
t.Error(errMsg("unable to parse expected JSON", err, msgAndArgs...))
return false
}

actualVal := map[string]interface{}{}
if err := json.Unmarshal([]byte(actual), &actualVal); err != nil {
t.Errorf(errMsg("unable to parse actual JSON", err, msgAndArgs...))
t.Error(errMsg("unable to parse actual JSON", err, msgAndArgs...))
return false
}

Expand All @@ -123,12 +123,12 @@ func AssertJSON(t *testing.T, expect, actual string, msgAndArgs ...interface{})
func AssertXML(t *testing.T, expect, actual string, container interface{}, msgAndArgs ...interface{}) bool {
expectVal := container
if err := xml.Unmarshal([]byte(expect), &expectVal); err != nil {
t.Errorf(errMsg("unable to parse expected XML", err, msgAndArgs...))
t.Error(errMsg("unable to parse expected XML", err, msgAndArgs...))
}

actualVal := container
if err := xml.Unmarshal([]byte(actual), &actualVal); err != nil {
t.Errorf(errMsg("unable to parse actual XML", err, msgAndArgs...))
t.Error(errMsg("unable to parse actual XML", err, msgAndArgs...))
}
return equal(t, expectVal, actualVal, msgAndArgs...)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/endpoints/v2/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ func TestLogDeprecated(t *testing.T) {
Logger: log.New(buffer, "", 0),
}, func(t *testing.T) {
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)
t.Error(diff)
}
}
},
Expand All @@ -1326,7 +1326,7 @@ func TestLogDeprecated(t *testing.T) {
Logger: log.New(buffer, "", 0),
}, func(t *testing.T) {
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)
t.Error(diff)
}
}
},
Expand All @@ -1352,7 +1352,7 @@ func TestLogDeprecated(t *testing.T) {
}

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

if verifyLog != nil {
Expand Down
8 changes: 4 additions & 4 deletions service/kinesis/internal/testing/eventstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func TestSubscribeToShard_ReadException(t *testing.T) {
expectedErr,
&types.InternalFailureException{Message: aws.String("this is an exception message")},
); len(diff) > 0 {
t.Errorf(diff)
t.Error(diff)
}
}

Expand Down Expand Up @@ -366,7 +366,7 @@ func TestSubscribeToShard_ReadUnmodeledException(t *testing.T) {
Message: "this is an unmodeled exception message",
},
); len(diff) > 0 {
t.Errorf(diff)
t.Error(diff)
}
}

Expand Down Expand Up @@ -437,7 +437,7 @@ func TestSubscribeToShard_ReadErrorEvent(t *testing.T) {
Message: "An error message",
},
); len(diff) > 0 {
t.Errorf(diff)
t.Error(diff)
}
}

Expand Down Expand Up @@ -478,7 +478,7 @@ func TestSubscribeToShard_ResponseError(t *testing.T) {
Message: "this is an exception message",
},
); len(diff) > 0 {
t.Errorf(diff)
t.Error(diff)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func TestStartStreamTranscription_ReadException(t *testing.T) {
expectedErr,
&types.BadRequestException{Message: aws.String("this is an exception message")},
); len(diff) > 0 {
t.Errorf(diff)
t.Error(diff)
}
}

Expand Down Expand Up @@ -328,7 +328,7 @@ func TestStartStreamTranscription_ReadUnmodeledException(t *testing.T) {
Message: "this is an unmodeled exception message",
},
); len(diff) > 0 {
t.Errorf(diff)
t.Error(diff)
}
}

Expand Down Expand Up @@ -390,7 +390,7 @@ func TestStartStreamTranscription_ReadErrorEvent(t *testing.T) {
Message: "An error message",
},
); len(diff) > 0 {
t.Errorf(diff)
t.Error(diff)
}
}

Expand Down Expand Up @@ -649,7 +649,7 @@ func TestStartStreamTranscription_ResponseError(t *testing.T) {
Message: "this is an exception message",
},
); len(diff) > 0 {
t.Errorf(diff)
t.Error(diff)
}
}

Expand Down

0 comments on commit 885de40

Please sign in to comment.