Skip to content

Commit

Permalink
fixup! Add RemotePersister
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur22 committed Feb 1, 2024
1 parent f6943fe commit ac20d5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions storage/file_persister.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (r *RemoteFilePersister) Persist(ctx context.Context, path string, data io.
}

if err := checkStatusCode(resp); err != nil {
return fmt.Errorf("uploading status code out of range: %w", err)
return fmt.Errorf("uploading: %w", err)
}

return nil
Expand Down Expand Up @@ -142,7 +142,7 @@ func (r *RemoteFilePersister) getPreSignedURL(ctx context.Context, path string)
defer resp.Body.Close() //nolint:errcheck

if err := checkStatusCode(resp); err != nil {
return "", fmt.Errorf("status code out of range: %w", err)
return "", err
}

return readResponseBody(resp)
Expand Down
8 changes: 4 additions & 4 deletions storage/file_persister_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestRemoteFilePersister(t *testing.T) {
"Run_id": "123456",
},
getPresignedURLResponse: http.StatusTooManyRequests,
wantError: "getting presigned url: status code out of range: request is being rate limited",
wantError: "getting presigned url: request is being rate limited",
},
{
name: "get_presigned_fails",
Expand All @@ -138,7 +138,7 @@ func TestRemoteFilePersister(t *testing.T) {
"Run_id": "123456",
},
getPresignedURLResponse: http.StatusInternalServerError,
wantError: "getting presigned url: status code out of range: status code is 500",
wantError: "getting presigned url: status code is 500",
},
{
name: "upload_rate_limited",
Expand All @@ -154,7 +154,7 @@ func TestRemoteFilePersister(t *testing.T) {
},
uploadResponse: http.StatusTooManyRequests,
getPresignedURLResponse: http.StatusOK,
wantError: "uploading status code out of range: request is being rate limited",
wantError: "uploading: request is being rate limited",
},
{
name: "upload_fails",
Expand All @@ -170,7 +170,7 @@ func TestRemoteFilePersister(t *testing.T) {
},
uploadResponse: http.StatusInternalServerError,
getPresignedURLResponse: http.StatusOK,
wantError: "uploading status code out of range: status code is 500",
wantError: "uploading: status code is 500",
},
}

Expand Down

0 comments on commit ac20d5b

Please sign in to comment.