Skip to content

test(agent): cover inject URL/option defaults - #955

Merged
skevetter merged 3 commits into
mainfrom
pkg-core-agent/inject-url-defaults-test
Aug 9, 2026
Merged

skevetter merged 3 commits into
mainfrom
pkg-core-agent/inject-url-defaults-test

Conversation

@devsy-app

@devsy-app devsy-app Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/agent (agent-runtime core category) — focused on the InjectOptions default-resolution logic that backs the DEVSY_AGENT_URL / AGENT_URL / GitHub-release precedence documented in pkg/options/resolve.go.

Issue found

The DEVSY_AGENT_URL side-effect paths in pkg/agent/inject.go had no direct unit-test coverage:

  • applyURLDefaults() — tag-style release URL → /download/ normalization (e.g. .../releases/tags/v1 → .../releases/download/v1).
  • applyPreferDownloadDefaults() — the two documented DEVSY_AGENT_URL side effects: PreferDownloadFromRemoteUrl = true and SkipVersionCheck = true.
  • applyEnvPreference() — DEVSY_AGENT_PREFER_DOWNLOAD parsing, including the edge case where an invalid bool string logs a warning and defaults to true (fail-open toward remote download).
  • The dev-build default path where neither env var is set (prefers local injection, skips version check).

These are exactly the resolution-order / config-default behaviors the reviewer is asked to protect, so a regression here would silently change agent binary download behavior. Tests pin them.

Change

New file pkg/agent/inject_defaults_test.go (test-only, no behavioral change):

  • TestApplyURLDefaults_NormalizesTagURL / PreservesNonTagURL / FillsFromEnvWhenEmpty
  • TestApplyPreferDownloadDefaults subtests:
    • custom_agent_url_prefers_remote_and_skips_version_check
    • prefer_download_env_true
    • prefer_download_env_false
    • prefer_download_env_invalid_defaults_true
    • default_dev_build_prefers_local
    • explicit_preference_preserved

Verification

  • task cli:format — clean.
  • task cli:lint:ci — 0 issues (only-new-issues, mirrors CI).
  • task cli:test — pkg/agent/... passes (ok); the only repo-wide failure is the known pre-existing pkg/git TestRepoClone* stale-assertion failure on origin/main, unrelated to this change (this PR touches only pkg/agent).

This PR was created by an AI agent as part of an automated daily package review job.

Add unit tests for InjectOptions URL and prefer-download default logic in pkg/agent/inject.go: applyURLDefaults tag->download normalization, applyPreferDownloadDefaults DEVSY_AGENT_URL/DEVSY_AGENT_PREFER_DOWNLOAD side effects, and explicit preference preservation. These DEVSY_AGENT_URL side-effect paths had no direct test coverage.
@netlify

netlify Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 5086240
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a78b10b2440cd00080f1814

@netlify

netlify Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 5086240
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a78b10bd9307e00089a5dab

@github-actions github-actions Bot added the size/m label Aug 9, 2026
@codacy-production

codacy-production Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 10 complexity · 2 duplication

Metric Results
Complexity 10
Duplication 2

View in Codacy

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

devsy-app Bot and others added 2 commits August 9, 2026 10:43
Break the TestApplyPreferDownloadDefaults subtests into top-level test functions to satisfy funlen, and replace Bool(true) with new(true) to satisfy the govet inline analyzer (matching production style in agent.go).
Signed-off-by: GitHub <noreply@github.com>
@skevetter
skevetter marked this pull request as ready for review August 9, 2026 17:30
@skevetter
skevetter enabled auto-merge (squash) August 9, 2026 17:30
@skevetter
skevetter merged commit 8b1d321 into main Aug 9, 2026
67 checks passed
@skevetter
skevetter deleted the pkg-core-agent/inject-url-defaults-test branch August 9, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant