use assert_cmd::Command;
use assert_fs::prelude::*;
use assert_fs::TempDir;
#[test]
fn fmt() {
let temp_dir = TempDir::new().unwrap();
let input_file = temp_dir.child("rule.yar");
input_file.write_str("rule test { condition: true }").unwrap();
Command::cargo_bin("yr")
.unwrap()
.arg("fmt")
.arg(input_file.path())
.assert()
.code(1);
Command::cargo_bin("yr")
.unwrap()
.arg("fmt")
.arg(input_file.path())
.assert()
.code(0); }
#[test]
fn utf8_error() {
let temp_dir = TempDir::new().unwrap();
let input_file = temp_dir.child("rule.yar");
input_file.write_binary(&[0xff, 0xff]).unwrap();
Command::cargo_bin("yr")
.unwrap()
.arg("fmt")
.arg(input_file.path())
.assert()
.stderr("error: invalid UTF-8 at [0..1]\n")
.code(1);
}