Skip to content

test: add comprehensive unit tests for Template::Plugins#455

Draft
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/unit-tests-plugins
Draft

test: add comprehensive unit tests for Template::Plugins#455
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/unit-tests-plugins

Conversation

@toddr-bot

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

Copy link
Copy Markdown
Contributor

What

49 unit tests for Template::Plugins — the plugin provider that loads and instantiates TT plugin modules.

Why

Template::Plugins had no unit tests. It's a critical load path: every [% USE Plugin %] directive routes through fetch() and _load(). The coverage gap meant regressions in factory caching, TOLERANT mode, and LOAD_PERL semantics were invisible.

How

Tests cover the full surface area without requiring disk-based .pm files:

  • Constructor: TOLERANT, LOAD_PERL flags, PLUGIN_BASE scalar/array coercion, PLUGINS merge with STD_PLUGINS, PLUGIN_FACTORY pre-population
  • fetch(): successful load, undef args default, FACTORY cache hit (single _load() call), CODE factory branch, prototype factory (object method new()), new() returning undef, new() dying
  • TOLERANT mode: all error paths converted to STATUS_DECLINED
  • PLUGIN_BASE search: multi-base resolution, dot-to-:: name conversion, case-insensitive lookup
  • LOAD_PERL: plain module loaded, context stripped from constructor args, unloadable module error
  • _load() errors: broken module name, TOLERANT vs non-tolerant handling
  • Instance isolation: FACTORY cache not shared between separate Plugins objects

LOAD_PERL tests use %INC pre-registration to avoid disk-based require, keeping tests self-contained.

Testing

perl -Ilib t/unit-plugins.t — 49 tests pass. Full suite: 3435 tests, all green.


Quality Report

Changes: 1 file changed, 407 insertions(+)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan

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