twc-rs 0.3.6

Fast single-binary CLI and interactive TUI dashboard for Timeweb Cloud
Documentation
use super::*;

#[test]
fn default_is_table() {
    let fmt = OutputFormat::default();
    assert_eq!(fmt, OutputFormat::Table);
}

#[test]
fn parse_table() {
    assert_eq!(OutputFormat::parse("table").unwrap(), OutputFormat::Table);
}

#[test]
fn parse_tbl() {
    assert_eq!(OutputFormat::parse("tbl").unwrap(), OutputFormat::Table);
}

#[test]
fn parse_table_case_insensitive() {
    assert_eq!(OutputFormat::parse("TABLE").unwrap(), OutputFormat::Table);
    assert_eq!(OutputFormat::parse("Table").unwrap(), OutputFormat::Table);
}

#[test]
fn parse_json() {
    assert_eq!(OutputFormat::parse("json").unwrap(), OutputFormat::Json);
}

#[test]
fn parse_js() {
    assert_eq!(OutputFormat::parse("js").unwrap(), OutputFormat::Json);
}

#[test]
fn parse_json_case_insensitive() {
    assert_eq!(OutputFormat::parse("JSON").unwrap(), OutputFormat::Json);
}

#[test]
fn parse_quiet() {
    assert_eq!(OutputFormat::parse("quiet").unwrap(), OutputFormat::Quiet);
}

#[test]
fn parse_q() {
    assert_eq!(OutputFormat::parse("q").unwrap(), OutputFormat::Quiet);
}

#[test]
fn parse_quiet_case_insensitive() {
    assert_eq!(OutputFormat::parse("QUIET").unwrap(), OutputFormat::Quiet);
}

#[test]
fn parse_invalid_format() {
    let err = OutputFormat::parse("xml").unwrap_err();
    assert!(err.contains("unknown output format: xml"));
    assert!(err.contains("expected table, json, yaml, or quiet"));
}

#[test]
fn parse_empty_string() {
    let err = OutputFormat::parse("").unwrap_err();
    assert!(err.contains("unknown output format"));
}

#[test]
fn display_table() {
    assert_eq!(OutputFormat::Table.to_string(), "table");
}

#[test]
fn display_json() {
    assert_eq!(OutputFormat::Json.to_string(), "json");
}

#[test]
fn display_quiet() {
    assert_eq!(OutputFormat::Quiet.to_string(), "quiet");
}

#[test]
fn equality_and_clone() {
    let a = OutputFormat::Json;
    let b = a;
    assert_eq!(a, b);
    let c = OutputFormat::Table;
    assert_ne!(a, c);
}

#[test]
fn parse_yaml_format() {
    assert_eq!(OutputFormat::parse("yaml").unwrap(), OutputFormat::Yaml);
    assert_eq!(OutputFormat::parse("yml").unwrap(), OutputFormat::Yaml);
}

#[test]
fn display_yaml() {
    assert_eq!(OutputFormat::Yaml.to_string(), "yaml");
}