chore(release): prepare public source release

This commit is contained in:
MercuryToolbox Release
2026-07-18 15:33:01 +08:00
commit 34d6a57f38
510 changed files with 163501 additions and 0 deletions
+79
View File
@@ -0,0 +1,79 @@
//! Integration tests for the `toon` command.
use std::fs;
use assert_cmd::Command;
use predicates::prelude::*;
use tempfile::tempdir;
fn cargo_command() -> Command {
Command::cargo_bin("toon").expect("binary")
}
#[test]
fn help_includes_pipeline_examples() {
cargo_command()
.arg("--help")
.assert()
.success()
.stdout(predicate::str::contains("Convert between JSON and TOON"))
.stdout(predicate::str::contains("'{\"ok\":true}' | toon"))
.stdout(predicate::str::contains(
"bat --style=plain --paging=never .\\fixtures\\toon\\records.jsonl | toon",
))
.stdout(predicate::str::contains("toon --from json --input-format jsonl").not())
.stdout(predicate::str::contains("--expand-paths <MODE>"));
}
#[test]
fn version_prints_package_version() {
cargo_command()
.arg("--version")
.assert()
.success()
.stdout(predicate::str::contains(env!("CARGO_PKG_VERSION")));
}
#[test]
fn jsonl_stdin_converts_to_toon_table() {
cargo_command()
.write_stdin("{\"name\":\"Ada\",\"score\":10}\n{\"name\":\"Bob\",\"score\":11}\n")
.assert()
.success()
.stdout(predicate::str::contains("name,score"))
.stdout(predicate::str::contains("Ada,10"))
.stdout(predicate::str::contains("Bob,11"));
}
#[test]
fn auto_detects_jsonl_files_without_extra_flags() {
let temp = tempdir().expect("tempdir");
let path = temp.path().join("records.jsonl");
fs::write(
&path,
"{\"name\":\"Ada\",\"score\":10}\n{\"name\":\"Bob\",\"score\":11}\n",
)
.expect("fixture");
cargo_command()
.arg(&path)
.assert()
.success()
.stdout(predicate::str::contains("name,score"))
.stdout(predicate::str::contains("Ada,10"))
.stdout(predicate::str::contains("Bob,11"));
}
#[test]
fn strict_flag_accepts_false_for_loose_indent_input() {
let temp = tempdir().expect("tempdir");
let path = temp.path().join("loose.toon");
fs::write(&path, "root:\n child: value\n").expect("fixture");
cargo_command()
.args(["--from", "toon", "--to", "json", "--strict", "false"])
.arg(&path)
.assert()
.success()
.stdout(predicate::str::contains("\"child\": \"value\""));
}