Skip to content

Add transform-test support - #55

Closed
ranquild wants to merge 9 commits into
mainfrom
transform-tests
Closed

ranquild wants to merge 9 commits into
mainfrom
transform-tests

Conversation

@ranquild

@ranquild ranquild commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What

mb transform-test list | get | create | update | delete | run over /api/transform-test.

A transform test pins a transform's behaviour without touching real data: every table the transform reads is replaced by an input fixture, the transform runs into a temp table, and each expectation checks that output. The temp tables are dropped when the run ends.

  • Inputs name a table and carry either format: "sql" with a query, or format: "rows" with columns (each with the database_type the warehouse accepts as a CAST target) and rows.
  • Expectations are type: "empty" (this SQL must return no rows) or type: "equals", which takes the same format split as an input.
  • run reports what each expectation found — the rows a comparison disagreed on, or a sample of what an empty query returned — and exits non-zero when the test does not pass, so it drops into CI as it stands.
  • get --full shows the inputs and expectations; the compact form is id, transform, name and description.

Create and update bodies are closed, matching the server's own closed maps, so a body cloned from get --full is refused client-side with the offending key named rather than earning an opaque 400 — strip id, entity_id, creator_id, created_at and updated_at to send it back.

Commands are gated at minVersion: 64, the first version serving the endpoint.

Testing

bun run check passes: tsc --noEmit, oxlint, oxfmt --check, 1336 unit tests across 120 files, lint:skills.

Wire-level unit tests cover every method in packages/client/src/resources/transform-test.test.ts — the list query with and without transform-id, get, create, update, delete, and run, including that the run report keeps the server's kebab-case keys (row-counts, extra-rows, cell-mismatches). packages/client/src/domain/transform-test.test.ts covers the closed write-path bodies both ways: the keys a cloned body is refused for, and that it parses once they are stripped.

No e2e lane was run: no released Metabase serves /api/transform-test yet — the endpoint is on an unmerged branch (metabase#82495). The e2e tier needs a live server, so this ships with unit coverage only, and an e2e suite should follow once a server with the endpoint is available.

🤖 Generated with Claude Code

A transform test pins a transform's behaviour without touching real data: every
table it reads is replaced by an input fixture, the transform runs into a temp
table, and each expectation checks that output.

`transform-test list/get/create/update/delete/run` over `/api/transform-test`,
with the schemas the endpoint speaks — inputs as SQL or inline rows,
expectations as `empty` or `equals`, and a run report naming what each
expectation found. `run` exits non-zero when the test does not pass, so it drops
into CI as it stands.

Gated at v64, the first version serving the endpoint.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ranquild
ranquild requested a review from alxnddr September 16, 2026 03:39
The server closes `::transform-test.create` and `::transform-test.update`, so a
body cloned from `get` earned an opaque 400. Closing them here names the
offending key instead; a stored test needs `id`, `entity_id`, `creator_id`,
`created_at` and `updated_at` stripped before it can be sent back, which the
command help, the README and the transform skill now say.

`get` projects through the compact view, so `--full` is what shows `inputs` and
`expectations` — the examples and docs advertise it. An `equals` expectation
needs `format: "sql"` or `format: "rows"`, which the docs omitted, leaving a
body written from them to fail on a three-branch union error.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ranquild ranquild self-assigned this Sep 16, 2026
ranquild and others added 2 commits September 15, 2026 23:43
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`equals` pins the exact rows; `empty` asserts an invariant the row data alone
would not show.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ranquild
ranquild marked this pull request as ready for review September 16, 2026 11:17
@github-actions

Copy link
Copy Markdown

Published @metabase/cli@0.3.1-alpha.transform-tests.3fbcf8b with dist-tag alpha-transform-tests.

Install: npm install -g @metabase/cli@alpha-transform-tests

@github-actions

Copy link
Copy Markdown

Published @metabase/cli@0.3.1-alpha.transform-tests.c0bc2d1 with dist-tag alpha-transform-tests.

Install: npm install -g @metabase/cli@alpha-transform-tests

# Conflicts:
#	packages/cli/skill-data/core/SKILL.md
#	packages/cli/src/runtime/command-help.test.ts
#	packages/client/src/domain/transform-test.ts
#	packages/client/src/index.ts
#	packages/client/src/resources/transform-test.test.ts
#	packages/client/src/resources/transform-test.ts
@github-actions

Copy link
Copy Markdown

Published @metabase/cli@0.3.1-alpha.transform-tests.d9ed765 with dist-tag alpha-transform-tests.

Install: npm install -g @metabase/cli@alpha-transform-tests

@ranquild ranquild closed this Oct 5, 2026
@ranquild
ranquild deleted the transform-tests branch October 5, 2026 16:18
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.

3 participants