Skip to content

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

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
test-improver/tracing-json-endpoint-coverage-121c2e56671c7cec
Draft

[test-improver] Improve tests for tracing package#7497
github-actions[bot] wants to merge 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>
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.

0 participants