Skip to content

test: cover pkg/template fill helpers - #1010

Merged
skevetter merged 1 commit into
mainfrom
pkg-core-agent/template-tests
Aug 14, 2026
Merged

skevetter merged 1 commit into
mainfrom
pkg-core-agent/template-tests

Conversation

@devsy-app

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

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/template — the FillTemplate and WriteFiles helpers that render the agent inject script from variable maps.

Issue found

pkg/template had no tests despite FillTemplate powering agent inject script generation (pkg/agent/inject.go uses it to render the inject script from a variable map). The behavior of edge cases (missing variables, unclosed actions, empty templates, WriteFiles permissions) was undocumented.

Change

Added pkg/template/fill_test.go with table-driven coverage:

  • FillTemplate: simple substitution, multiple vars, repeated var reused, no-vars passthrough, missing-var `` sentinel, unclosed-action parse error, empty template.
  • WriteFiles: flat file content + 0o600 permission assertions, nested-path failure (documents no-mkdir behavior), missing-folder error.

Pure test additions — no behavioral changes. Brings pkg/template coverage to 92.3%.

Verification performed

  • task cli:format — clean (gofmt/gci/gofumpt/golines).
  • task cli:lint:ci — 0 new issues (full golangci-lint run ./pkg/template/... also 0 issues: resolved goconst duplicate-string and gosec G304 via repo-convention // #nosec G304 on temp paths).
  • task cli:test — pkg/template passes. Only the documented pre-existing pkg/git failures (TestRepoCloneArgsThroughRunner, TestRepoCloneFromInfoBranch, TestRepoCloneFromInfoHelper) remain on origin/main; this change does not touch pkg/git.

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

pkg/template had no tests despite powering agent inject script generation via FillTemplate. Add table-driven tests for FillTemplate (substitution, multiple/reused vars, no-vars passthrough, missing-var no-value sentinel, unclosed-action parse error, empty template) and WriteFiles (content + 0o600 perms, nested-path failure documents no-mkdir behavior, missing-folder error). Brings pkg/template coverage to 92.3% with 0 new lint issues.
@netlify

netlify Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

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

@netlify

netlify Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

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

@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 critical

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Security 1 critical

View in Codacy

🟢 Metrics 9 complexity · 0 duplication

Metric Results
Complexity 9
Duplication 0

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.

@skevetter
skevetter marked this pull request as ready for review August 13, 2026 23:20
@skevetter
skevetter merged commit f03efa7 into main Aug 14, 2026
115 of 117 checks passed
@skevetter
skevetter deleted the pkg-core-agent/template-tests branch August 14, 2026 04:59
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