Skip to content

Conversation

@julio-lopez
Copy link
Collaborator

Test without a proxy environment variable

Authored by: @andrason

Test without a proxy environment variable

Authored by: @andrason
@julio-lopez julio-lopez requested a review from Copilot August 22, 2025 04:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the azure.TestUserAgent test by changing its approach from using a proxy environment variable to directly testing the User-Agent header with a mock HTTP server.

  • Moves the test from azure_storage_test.go to a new file azure_ua_test.go
  • Replaces proxy-based testing with direct HTTP server mocking
  • Changes from testing client creation failure to testing actual blob operations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
repo/blob/azure/azure_ua_test.go New test file containing the refactored User-Agent test using direct HTTP mocking
repo/blob/azure/azure_storage_test.go Removes the old TestUserAgent function and unused imports

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

)

func TestUserAgent(t *testing.T) {
ctx := t.Context()
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using testlogging.Context(t) instead of t.Context() to ensure proper test logging context, which appears to be the pattern used in the codebase based on the removed test.

Suggested change
ctx := t.Context()
"github.com/kopia/kopia/internal/testlogging"
)
func TestUserAgent(t *testing.T) {
ctx := testlogging.Context(t)

Copilot uses AI. Check for mistakes.

handler := func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("test"))
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The explicit blank identifier assignment _, _ = w.Write(...) is unnecessary. In test code, you can simply use w.Write([]byte("test")) without the assignment.

Suggested change
_, _ = w.Write([]byte("test"))
w.Write([]byte("test"))

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Aug 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.39%. Comparing base (cb455c6) to head (6d8d77d).
⚠️ Report is 634 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4780      +/-   ##
==========================================
+ Coverage   75.86%   76.39%   +0.52%     
==========================================
  Files         470      530      +60     
  Lines       37301    40443    +3142     
==========================================
+ Hits        28299    30897    +2598     
- Misses       7071     7503     +432     
- Partials     1931     2043     +112     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@julio-lopez julio-lopez marked this pull request as ready for review August 22, 2025 05:07
@julio-lopez julio-lopez merged commit 9becb25 into kopia:master Aug 22, 2025
30 of 31 checks passed
@julio-lopez julio-lopez deleted the up-azure-user-agent-test-fix branch August 22, 2025 05:07
julio-lopez added a commit that referenced this pull request Aug 22, 2025
Leverage `require.Eventually` to prevent indefinite test
hangs / timeouts, removes blocking receive op on a channel.

Additional cleanups:
- rename test file
- remove unused const
- consistently use `testloggin.Context(t)`
- consistently leverage assertions from the `testify` package

Refs:
- #4780
- #4777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants