Skip to content

test: add comprehensive unit tests for Template::Provider#452

Draft
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/test-provider
Draft

test: add comprehensive unit tests for Template::Provider#452
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/test-provider

Conversation

@toddr-bot

@toddr-bot toddr-bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What

85 unit test assertions for Template::Provider, the template loading/compiling/caching layer.

Why

Provider is one of the most complex modules in TT — it handles file loading, INCLUDE_PATH resolution, LRU caching with a doubly-linked list, compiled template management, and Unicode BOM detection. None of these internals had dedicated unit test coverage; existing t/provider.t only exercises it indirectly through the template engine.

How

Direct method-level tests using Test::More with File::Temp for isolated filesystem fixtures. Coverage spans:

  • Constructor: option defaults, CACHE_SIZE normalization, INCLUDE_PATH coercion, DELIMITER, ENCODING, DEFAULT, STAT_TTL
  • paths(): static lists, blank filtering, coderef generators, object generators, error propagation, MAX_DIRS limit
  • _template_content/_template_modified/_modified: file reads, error paths, stat checks
  • _load(): scalar refs, file handles, file paths, aliases, TOLERANT mode
  • fetch(): absolute/relative/include-path routing, TOLERANT downgrades, DEFAULT fallback, scalar refs, file handles
  • load(): raw content retrieval (INSERT semantics) with same path-type routing
  • store/_store: cache insertion, LRU eviction at SIZE limit, head/tail pointer integrity
  • Negative cache: NOTFOUND population on miss, STAT_TTL expiry
  • _compiled_filename/_compiled_is_current: COMPILE_EXT/DIR path construction, mtime comparison, result caching
  • COMPILE_DIR: on-disk compiled file creation
  • _decode_unicode: UTF-8 BOM detection, ENCODING fallback, already-decoded passthrough
  • DESTROY: linked list circular reference cleanup
  • RELATIVE_PATH regex: pattern matching verification

Testing

perl -Ilib t/provider_methods.t — 85/85 pass. Full make test passes with no regressions.


Quality Report

Changes: 1 file changed, 987 insertions(+)

Code scan: 1 issue(s) found

  • t/provider_methods.t:0 — 987 lines added

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan

85 test assertions covering the template loading, compiling, and caching
layer. Tests verify constructor options, INCLUDE_PATH resolution with
static/dynamic/object generators, fetch() path routing (absolute,
relative, include path, refs), load() for raw content, LRU cache
eviction, negative caching, STAT_TTL refresh, compiled template
management, Unicode BOM decoding, and DESTROY cleanup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant