Skip to content

Expand test coverage for dig validation, template node types, and classifyCallError #9

Description

@lanycrost

Problem statement

Code review identified several uncovered branches across the templating and transport packages. Key gaps:

Templating (validation.go)

  • rootFromDigArgs — 0% coverage. The dig function root extraction is completely untested. Needs tests for {{ dig "key" "subkey" .steps }} and dot-root patterns.
  • walkTemplateNode — 21.1% coverage. Missing tests for IfNode, RangeNode (including AllowRange rejection), WithNode, and TemplateNode (inclusion rejection).
  • walkJSONTemplates — No test for $bubuTemplate with non-string value (type error branch).
  • rootNameFromNode — Missing tests for ChainNode with DotNode, PipeNode, and CommandNode bases.

Transport (dial.go)

  • classifyCallError — Missing tests for: (a) timeout=0 with parent DeadlineExceeded (should NOT wrap with timeout message), (b) callback returns non-context error passthrough, (c) callback returns nil but context is Canceled.
  • deriveCallContext — No test for nil context or zero/negative timeout.

Proposed change

Add the following test functions:

// templating/validation_test.go
TestValidateTemplateStringWithIfNode
TestValidateTemplateStringWithRangeNodeAllowed
TestValidateTemplateStringWithRangeNodeRejected
TestValidateTemplateStringWithWithNode
TestValidateTemplateStringRejectsTemplateInclusion
TestValidateTemplateStringRejectsDigBypass
TestValidateJSONTemplatesRejectsNonStringExprKey
TestValidateTemplateStringDigWithDotRoot

// runtime/transport/connector/dial_test.go
TestCallWithTimeoutPassesCallbackError
TestCallWithTimeoutZeroTimeoutDoesNotWrapDeadline
TestCallWithTimeoutNilContext
TestCallWithTimeoutSuccessButContextCancelled

Affected area

  • templating
  • runtime/*

Compatibility / migration

Test-only changes. No behavior changes.

Alternatives considered

N/A — these are straightforward missing test cases.

Additional context

Current coverage: templating 49.9%, runtime/transport/connector 65.4%. These tests would significantly improve branch coverage in the most critical paths. Identified during code review.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/templatingTemplate parsing, validation, or evaluation changes.area/transportBinding, protocol, connector, or transport runtime changes.good first issueSmall, well-scoped tasks for new contributors.help wantedLooking for community contributions.kind/testsTesting, CI, or verification-only changes.priority/lowNice-to-have or backlog item.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions