Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
WalkthroughAdds a public method RefreshToken on Client to exchange a refresh token for a new token pair via POST /auth/refresh (Authorization: Bearer ), returning TokenResponse or an error; also adds tests covering success and error responses. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
smsgateway/client_test.go (1)
998-1000: Assert wrapped error context in the failure case.At Line 998-Line 1000, the error path only checks non-nil. Consider also asserting the expected wrapped message (e.g.,
"failed to refresh token") so regressions in error context are caught.Proposed tightening
import ( "context" "io" "net/http" "net/http/httptest" "net/url" "reflect" + "strings" "testing" "time" @@ resp, err := client.RefreshToken(context.Background(), tt.refreshToken) if (err != nil) != tt.wantErr { t.Errorf("RefreshToken error = %v, wantErr %v", err, tt.wantErr) } + if tt.wantErr && err != nil && !strings.Contains(err.Error(), "failed to refresh token") { + t.Errorf("RefreshToken error = %v, expected wrapped context", err) + } if !tt.wantErr && !reflect.DeepEqual(resp, tt.want) { t.Errorf("RefreshToken response = %v, want %v", resp, tt.want) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@smsgateway/client_test.go` around lines 998 - 1000, The test currently only verifies presence/absence of an error for RefreshToken; tighten it by asserting the expected wrapped error message when an error is expected: in the test block around the RefreshToken call (the failing branch where (err != nil) != tt.wantErr is checked), if tt.wantErr is true assert that err is non-nil and that its message contains the expected context (e.g., "failed to refresh token") — use err.Error() string containment or errors.Is/errors.As if you have a sentinel or wrapped error type — so regressions that drop the error context are caught.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@smsgateway/client_test.go`:
- Around line 998-1000: The test currently only verifies presence/absence of an
error for RefreshToken; tighten it by asserting the expected wrapped error
message when an error is expected: in the test block around the RefreshToken
call (the failing branch where (err != nil) != tt.wantErr is checked), if
tt.wantErr is true assert that err is non-nil and that its message contains the
expected context (e.g., "failed to refresh token") — use err.Error() string
containment or errors.Is/errors.As if you have a sentinel or wrapped error type
— so regressions that drop the error context are caught.
76d6562 to
c1a09eb
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Waiting for server release... |
Motivation
Description
RefreshToken(ctx context.Context, refreshToken string) (TokenResponse, error)toClient, which POSTs to/auth/refreshwith anAuthorization: Bearer <refreshToken>header and decodes the response intoTokenResponse, returning a wrapped error on failure.Testing
go test ./...and the test suite completed successfully.Codex Task
Summary by CodeRabbit