Skip to content

Commit

Permalink
fix getter func for attempt results to return bool instead of an err
Browse files Browse the repository at this point in the history
  • Loading branch information
skotambkar committed Jan 12, 2021
1 parent 132883e commit e8e3a94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
9 changes: 2 additions & 7 deletions aws/retry/metadata.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package retry

import (
"fmt"
"github.com/aws/smithy-go/middleware"
)

Expand All @@ -11,13 +10,9 @@ type attemptResultsKey struct {
}

// GetAttemptResults retrieves attempts results from middleware metadata.
func GetAttemptResults(metadata middleware.Metadata) (AttemptResults, error) {
func GetAttemptResults(metadata middleware.Metadata) (AttemptResults, bool) {
m, ok := metadata.Get(attemptResultsKey{}).(AttemptResults)
if !ok {
return AttemptResults{},
fmt.Errorf("failed to fetch attempt results from metadata")
}
return m, nil
return m, ok
}

// AttemptResults represents struct containing metadata returned by all request attempts.
Expand Down
6 changes: 3 additions & 3 deletions aws/retry/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ func TestAttemptMiddleware(t *testing.T) {
t.Error(diff)
}

attemptResults, err := GetAttemptResults(metadata)
if err != nil {
t.Fatalf("expected no error, got %v", err)
attemptResults, ok := GetAttemptResults(metadata)
if !ok {
t.Fatalf("expected metadata to contain attempt results, got none")
}
if e, a := tt.ExpectResults, attemptResults; !reflect.DeepEqual(e, a) {
t.Fatalf("expected %v, got %v", e, a)
Expand Down

0 comments on commit e8e3a94

Please sign in to comment.