Files
matcha/tests/cli.rs
chrnx 5c8f72b409 feat(openapi): the OpenAPI document, and the paperwork the crate shipped without
`Cargo.toml` has declared `license = "MIT"` since the first release and the
published crate carried no license text, so anyone vendoring the source had the
claim without the grant. `LICENSE` is that text. `DCO` is the certificate the
README has been requiring a sign-off against without shipping, and
`CONTRIBUTING.md` says how — including that GitHub is a mirror of `main` and
tags, so a pull request there is carried upstream by a maintainer rather than
merged, which would put the two forges out of sync.

`CHANGELOG.md` reconstructs 26.7.0 and 26.8.0-beta.0 from their tags. The CLI
ships on its own version line, so the header says what that does and does not
mean about the core version a scaffold is pinned to, and each entry says when
that pin moved.

`matcha openapi` prints core's structural OpenAPI 3.1 for the route table —
`--title`, `--api-version`, `--out`. It reuses the entry resolution and the
generated-script runner that `graph` and `explain` already had, so it is the
same `app.ready()` that resolves the graph without booting providers. Structural
is the honest word: paths, methods and parameters come from the decorators, and
nothing invents a response schema.

The loose end from the capability table is closed. `cli.rs` still carried its own
copies of the `create` kinds and the `add` capabilities, so adding either meant
editing two files that could disagree — a value the parser accepts and the
dispatcher rejects. Both now read the list from the module that owns it, and the
three `create` piece kinds became rows in a table rather than near-identical
match arms, which also retires a `too_many_arguments` allow.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-05 16:01:49 -05:00

50 lines
1.4 KiB
Rust

use assert_cmd::Command;
use predicates::str::contains;
#[test]
fn help_lists_all_subcommands() {
Command::cargo_bin("matcha")
.unwrap()
.arg("--help")
.assert()
.success()
.stdout(contains("new"))
.stdout(contains("run"))
.stdout(contains("create"))
.stdout(contains("add"))
.stdout(contains("graph"))
.stdout(contains("explain"))
.stdout(contains("openapi"))
.stdout(contains("doctor"));
}
/// clap's accepted values and the values `run` dispatches on come from one list
/// per command now. This is what proves the wiring reached clap — a regression
/// would take the parser and the dispatcher out of step, which shows up as a
/// value the CLI accepts and then refuses.
#[test]
fn create_and_add_advertise_every_value_they_accept() {
for (command, values) in [
("create", vec!["module", "controller", "step", "provider"]),
("add", vec!["sse", "stream", "buffer", "ws", "upload"]),
] {
let mut assertion = Command::cargo_bin("matcha")
.unwrap()
.args([command, "--help"])
.assert()
.success();
for value in values {
assertion = assertion.stdout(contains(value));
}
}
}
#[test]
fn new_requires_a_name() {
Command::cargo_bin("matcha")
.unwrap()
.arg("new")
.assert()
.failure(); // missing <name>
}