mod common;
use common::sqry_bin;
use assert_cmd::Command;
use std::fs;
use tempfile::tempdir;
#[test]
fn query_validation_fail_exit_code_2() {
let dir = tempdir().unwrap();
let file = dir.path().join("lib.rs");
fs::write(&file, "pub fn foo() {}\n").unwrap();
let path = sqry_bin();
Command::new(&path)
.arg("index")
.arg(dir.path())
.assert()
.success();
fs::remove_file(&file).unwrap();
Command::new(&path)
.args(["query", "kind:function"])
.arg(dir.path())
.args(["--validate", "fail"])
.assert()
.code(2);
}
#[test]
fn search_validation_fail_exit_code_2() {
let dir = tempdir().unwrap();
let file = dir.path().join("lib.rs");
fs::write(&file, "pub fn bar() {}\n").unwrap();
let path = sqry_bin();
Command::new(&path)
.arg("index")
.arg(dir.path())
.assert()
.success();
fs::remove_file(&file).unwrap();
Command::new(&path)
.args(["--fuzzy", "search", "bar"]) .arg(dir.path())
.args(["--validate", "fail"]) .assert()
.code(2);
}