Repository navigation
test(templates): 80 tests for the template engine — schema, render, compose, registry - #11
Merged
Merged
Conversation
ployer-templates had no tests. It is the crate that turns a registry YAML into the container spec Ployer deploys, so a silent regression there misconfigures every installed service. Covers credential generation (length, uniqueness, URI-safety), volume naming, input resolution and its empty-string fallback, placeholder substitution, the six-key compose subset (including the keys it silently drops), and host port publishing round-trips. Catalog content is deliberately not asserted here; the registry lives in ployer-website and is tested there.
The disk cache is re-hashed on every read, so a tampered or truncated cache file must surface as HashMismatch rather than being parsed. The cache filename carries the hash prefix, which is what stops an upgraded template being masked by the copy already on disk. Network paths are not exercised; these cover hashing, cache-key naming and the on-disk index fallback.
…hanges
Rebasing onto main pulled in three breaking changes:
- `ac178ed` dropped `icon` from `Template` and `IndexEntry`, so the six
assertions that referenced it no longer compile.
- `0c80422` added a seventh `app_slug` parameter to `substitute()`.
- `0c80422` also added its own `render_tests.rs`. Both files are kept: its
four `{{ app.slug }}` tests are merged in alongside the engine tests, with
a single `ctx` helper rather than two.
Also adds two tests for a cross-repo hazard the schema change opened up: the
published registry still ships `icon` on every template and index entry, and
the two repos deploy independently, so the parser must keep ignoring the key.
Without that tolerance every install would fail on a field nobody reads.
The workspace as a whole is not rustfmt-clean (337 files differ on main), so this formats only the four test modules this branch owns rather than touching unrelated production files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
80 new tests for the
ployer-templatescrate — the code path that turns a remoteregistry entry into a running container. It had almost no coverage; a template
that renders wrong is an install that fails on the user's machine, not in CI.
Workspace goes from 143 → 223 passing Rust tests. No production code changes
beyond four
#[cfg(test)] moddeclarations.schema_tests.rsTemplate,IndexEntry, inputs, generators, ports, volumes; the API serialisation contract the dashboard readsrender_tests.rs{{ app.slug }}, generated secrets, missing/unknown inputs, container naming via the realApplication::slug()compose_tests.rsregistry_tests.rs(
+Nis new on this branch; the rest already existed onmain. 80 new tests,ployer-templatesgoes 6 → 86.)What it asserts, specifically
ignored; absent optional sections default to empty rather than erroring.
versionparses as either a number or a string.composebody, noslug, an unknown inputtype, or a port above the
u16range are all rejected.HashMismatch; a corrupt index on disk is an error, not a panic; a cache missis an error so the caller refetches.
GET /api/v1/templates/:slugreturnsTemplateverbatim, so the JSON key names are published API. Round-trip andkey-name tests pin them.
Deliberately not covered
cache and hashing through a temp dir; render tests build fixtures in memory.
docker compose upis not exercised here — that belongs in anintegration test with a daemon, and I would rather have none than a flaky one.
is not rustfmt-clean (337 files differ on
main), so the last commit formatsonly the four test modules this branch adds rather than burying the tests in
unrelated reformatting.
Base and rebase notes
Rebased onto
c652aea(currentmain, post-#7). Two tests on the originalbranch —
an_index_entry_carrying_the_removed_icon_key_still_parsesanda_template_carrying_the_removed_icon_key_still_parses— landed upstream in #7while this branch sat unpushed. The duplicates are dropped; #7's versions,
which carry the live-registry verification in their comments, are the ones kept.
A marker comment at the old location says where they went.
Pre-rebase state is preserved at
backup/template-engine-coverage-prerebase.Gates (run against
c652aea, not the stale base)The 223 figure was re-measured after the rebase. The previous measurement was
against
f314846, whichmainhas since moved past.