Skip to content

[test-improver] Improve tests for tracing package#7497

Merged
lpcox merged 1 commit into
mainfrom
test-improver/tracing-json-endpoint-coverage-121c2e56671c7cec
Jun 14, 2026
Merged

[test-improver] Improve tests for tracing package#7497
lpcox merged 1 commit into
mainfrom
test-improver/tracing-json-endpoint-coverage-121c2e56671c7cec

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Test Improvements: resolve_endpoint_test.go

File Analyzed

  • Test File: internal/tracing/resolve_endpoint_test.go
  • Package: internal/tracing
  • Lines Changed: +34 insertions

Improvements Made

1. Increased Coverage

  • ✅ Added TestResolveExtraEndpoints_JSONArray_EmptyURL — verifies that a JSON-format GH_AW_OTLP_ENDPOINTS entry with an empty url field is silently skipped while valid entries are still returned
  • ✅ Added TestResolveExtraEndpoints_JSONArray_WhitespaceURL — verifies that a whitespace-only url field is also skipped
  • ✅ Added TestResolveExtraEndpoints_JSONArray_AllEmptyURLsReturnsNil — verifies that when all entries have empty/whitespace URLs, nil is returned (no valid endpoints)

Previous Coverage: 97.2%
New Coverage: 97.5%
Improvement: +0.3%

The previously uncovered statement was the continue at config_resolver.go:217–218 inside resolveJSONExtraEndpoints:

if normalized == "" {
    continue   // ← was never hit
}

This path is triggered when a JSON array entry like {"url":""} or {"url":" "} normalizes to an empty string.

2. Better Testing Patterns

  • ✅ Added missing "empty string returns empty" case to TestNormalizeExtraEndpoint table, making the table exhaustive (empty string and whitespace-only are now both explicit cases)
  • ✅ New tests follow the established file pattern (t.Setenv + resolveExtraEndpoints(nil) + require.Len / assert.Equal / assert.Nil)

Test Execution

All tests pass:

=== RUN   TestResolveExtraEndpoints_JSONArray_EmptyURL
--- PASS: TestResolveExtraEndpoints_JSONArray_EmptyURL (0.00s)
=== RUN   TestResolveExtraEndpoints_JSONArray_WhitespaceURL
--- PASS: TestResolveExtraEndpoints_JSONArray_WhitespaceURL (0.00s)
=== RUN   TestResolveExtraEndpoints_JSONArray_AllEmptyURLsReturnsNil
--- PASS: TestResolveExtraEndpoints_JSONArray_AllEmptyURLsReturnsNil (0.00s)
PASS
ok  github.com/github/gh-aw-mcpg/internal/tracing  0.024s  coverage: 97.5% of statements

All 25 Go packages pass (make agent-finished Go tests OK; Rust tests skipped due to Cargo registry network restriction in CI environment).

Why These Changes?

resolveJSONExtraEndpoints defensively skips endpoints that normalize to an empty string, but this guard was never exercised by the test suite. The three new tests close that gap using the same t.Setenv + direct function call pattern already established in the file, making the defensive code provably correct and covered.


Generated by Test Improver Workflow
Focuses on better patterns, increased coverage, and more stable tests

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • index.crates.io

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "index.crates.io"

See Network Configuration for more information.

Generated by Test Improver · 2.3K AIC · ⊞ 29.5K ·

…JSON endpoints

Add missing test cases to resolve_endpoint_test.go that cover the
previously-uncovered 'continue' statement in resolveJSONExtraEndpoints
when a JSON array entry has an empty or whitespace-only URL field.

Also add a missing 'empty string returns empty' case to
TestNormalizeExtraEndpoint to make the table complete.

Coverage: 97.2% → 97.5%

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves test coverage in internal/tracing by exercising previously-uncovered defensive behavior in resolveJSONExtraEndpoints and by making the normalizeExtraEndpoint table test more exhaustive.

Changes:

  • Added a table-case asserting normalizeExtraEndpoint("") returns "".
  • Added three tests for JSON-array GH_AW_OTLP_ENDPOINTS entries where "url" is empty/whitespace, ensuring those entries are skipped and that “all invalid” returns nil.
Show a summary per file
File Description
internal/tracing/resolve_endpoint_test.go Adds targeted test cases to cover empty/whitespace JSON url entries and expands normalizeExtraEndpoint test table coverage.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@lpcox lpcox merged commit cb00b68 into main Jun 14, 2026
24 checks passed
@lpcox lpcox deleted the test-improver/tracing-json-endpoint-coverage-121c2e56671c7cec branch June 14, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants