---
id: TASK-16
title: Add unit tests for Utils.interpolate and Utils.interpolate_recursive
status: Done
assignee:
  - codex
created_date: '2026-02-19 16:59'
updated_date: '2026-02-19 17:02'
labels: []
dependencies:
  - TASK-15.1
  - TASK-15.2
references:
  - lua/zync/lib/utils.lua
  - spec/lib_spec/utils_spec.lua
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Add targeted unit tests for zync.lib.utils interpolation helpers, including direct string replacement and recursive table interpolation behavior.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Tests cover Utils.interpolate string replacement (including missing keys leave placeholders).
- [x] #2 Tests cover Utils.interpolate_recursive on nested tables with mixed types (strings/numbers/booleans) and nested tables inside arrays.
- [x] #3 Tests cover recursive interpolation using a provided source table with chained placeholders.
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1) Extend spec/lib_spec/utils_spec.lua with tests for Utils.interpolate covering basic replacement and missing keys leaving placeholders unchanged.
2) Add Utils.interpolate_recursive tests for nested tables/arrays containing strings, numbers, booleans; assert non-strings are preserved and strings interpolated.
3) Add chained placeholder test using a source map to verify recursive resolution.
4) Run busted -c spec/lib_spec/utils_spec.lua and update acceptance criteria/notes.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Added Utils.interpolate and Utils.interpolate_recursive specs in spec/lib_spec/utils_spec.lua covering placeholder replacement, recursive nested tables/arrays, and chained placeholder resolution.

Tests run: busted -c spec/lib_spec/utils_spec.lua (11 successes).

Full suite run: busted -c (141 successes).
<!-- SECTION:NOTES:END -->

## Final Summary

<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Summary:
- Added Utils.interpolate tests for placeholder replacement and missing-key behavior.
- Added Utils.interpolate_recursive tests for nested tables/arrays with mixed types and chained placeholder resolution.

Tests:
- busted -c spec/lib_spec/utils_spec.lua (11 successes)

Notes:
- No Definition of Done items were defined for this task.
<!-- SECTION:FINAL_SUMMARY:END -->
