forked from Crockan/MercuryToolbox
chore(release): prepare public source release
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
//! Integration tests for the `csvshape` command.
|
||||
|
||||
use std::fs;
|
||||
|
||||
use assert_cmd::Command;
|
||||
use predicates::prelude::*;
|
||||
use tempfile::tempdir;
|
||||
|
||||
fn cargo_command() -> Command {
|
||||
Command::cargo_bin("csvshape").expect("binary")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn summarizes_csv_as_json() {
|
||||
let temp = tempdir().expect("tempdir");
|
||||
let path = temp.path().join("sample.csv");
|
||||
fs::write(
|
||||
&path,
|
||||
"name,age,city\nAda,34,London\nBob,,Paris\nCara,29,Paris\n",
|
||||
)
|
||||
.expect("fixture");
|
||||
|
||||
cargo_command()
|
||||
.arg("--json")
|
||||
.arg(&path)
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("\"row_count\":3"))
|
||||
.stdout(predicate::str::contains("\"column_count\":3"))
|
||||
.stdout(predicate::str::contains("\"name\":\"age\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn help_includes_csv_examples() {
|
||||
cargo_command()
|
||||
.arg("--help")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains(
|
||||
"csvshape [OPTIONS] diff <BEFORE> <AFTER>",
|
||||
))
|
||||
.stdout(predicate::str::contains("--sample-rows"))
|
||||
.stdout(predicate::str::contains("ConvertFrom-Json"))
|
||||
.stdout(predicate::str::contains("csvshape"));
|
||||
}
|
||||
Reference in New Issue
Block a user