#![allow(clippy::unwrap_used)] #![allow(clippy::expect_used)] #![allow(deprecated)]
#![allow(non_snake_case)]
use assert_cmd::Command;
use predicates::prelude::*;
fn alimentar_repl() -> Command {
let mut cmd = Command::cargo_bin("alimentar").expect("Failed to find alimentar binary");
cmd.arg("repl");
cmd
}
#[test]
fn test_ALIM_REPL_001_repl_starts_and_quits() {
alimentar_repl()
.write_stdin("quit\n")
.assert()
.success()
.stdout(predicate::str::contains("alimentar"))
.stdout(predicate::str::contains("Goodbye!"));
}
#[test]
fn test_ALIM_REPL_001_repl_handles_empty_input() {
alimentar_repl()
.write_stdin("\n\nexit\n")
.assert()
.success()
.stdout(predicate::str::contains("alimentar"));
}
#[test]
fn test_ALIM_REPL_001_repl_handles_eof() {
alimentar_repl()
.write_stdin("")
.assert()
.success()
.stdout(predicate::str::contains("alimentar"))
.stdout(predicate::str::contains("Goodbye!"));
}
#[test]
fn test_ALIM_REPL_001_repl_accepts_exit() {
alimentar_repl()
.write_stdin("exit\n")
.assert()
.success()
.stdout(predicate::str::contains("Goodbye!"));
}
#[test]
fn test_ALIM_REPL_001_repl_accepts_q_shorthand() {
alimentar_repl()
.write_stdin("q\n")
.assert()
.success()
.stdout(predicate::str::contains("Goodbye!"));
}
#[test]
fn test_ALIM_REPL_004_repl_shows_help() {
alimentar_repl()
.write_stdin("help\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("help"))
.stdout(predicate::str::contains("quit"));
}
#[test]
fn test_ALIM_REPL_004_repl_shows_help_shorthand() {
alimentar_repl()
.write_stdin("?\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("help"));
}
#[test]
fn test_ALIM_REPL_004_repl_topic_help() {
alimentar_repl()
.write_stdin("help quality\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("quality"));
}
#[test]
fn test_ALIM_REPL_006_repl_shows_history() {
alimentar_repl()
.write_stdin("info\nhistory\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("info"));
}
#[test]
fn test_ALIM_REPL_006_repl_exports_history() {
alimentar_repl()
.write_stdin("info\nhistory --export\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("#!/usr/bin/env bash"))
.stdout(predicate::str::contains("alimentar session export"));
}
#[test]
fn test_ALIM_REPL_007_repl_datasets_command() {
alimentar_repl()
.write_stdin("datasets\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("No datasets loaded"));
}
#[test]
fn test_ALIM_REPL_007_repl_info_no_dataset() {
alimentar_repl()
.write_stdin("info\nquit\n")
.assert()
.success()
.stderr(predicate::str::contains("No active dataset"));
}
#[test]
fn test_ALIM_REPL_007_repl_schema_no_dataset() {
alimentar_repl()
.write_stdin("schema\nquit\n")
.assert()
.success()
.stderr(predicate::str::contains("No active dataset"));
}
#[test]
fn test_ALIM_REPL_007_repl_head_no_dataset() {
alimentar_repl()
.write_stdin("head\nquit\n")
.assert()
.success()
.stderr(predicate::str::contains("No active dataset"));
}
#[test]
fn test_ALIM_REPL_error_unknown_command() {
alimentar_repl()
.write_stdin("foobar\nquit\n")
.assert()
.success()
.stderr(predicate::str::contains("Unknown command"));
}
#[test]
fn test_ALIM_REPL_error_load_missing_path() {
alimentar_repl()
.write_stdin("load\nquit\n")
.assert()
.success()
.stderr(predicate::str::contains("requires"));
}
#[test]
fn test_ALIM_REPL_error_quality_missing_subcommand() {
alimentar_repl()
.write_stdin("quality\nquit\n")
.assert()
.success()
.stderr(predicate::str::contains("requires subcommand"));
}