Skip to content

Commit

Permalink
Add tests for to_grep
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Jul 25, 2024
1 parent d3681bc commit bc4fdb9
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,43 @@ fn search_returns_matching_js_function_line_with_one_thread() {
assert_eq!(expected, common::do_search(args));
}

#[rstest]
fn to_grep_formats_message_without_number() {
let file_path = common::get_default_fixture_for_file_type_string("js").unwrap();
let query = String::from("parseQuery");
let expected_result = common::get_expected_search_result_for_file_type("js");
let expected = format!("{}:{}", expected_result.file_path, expected_result.text);
let file_type_string = String::from("js");
let mut args = common::make_args(query, Some(file_path), Some(file_type_string));
args.line_number = false;
args.no_color = true;
let actual = common::do_search(args);
for result in actual {
assert_eq!(expected, result.to_grep());
}
}

#[rstest]
fn to_grep_formats_message_with_number() {
let file_path = common::get_default_fixture_for_file_type_string("js").unwrap();
let query = String::from("parseQuery");
let expected_result = common::get_expected_search_result_for_file_type("js");
let expected = format!(
"{}:{}:{}",
expected_result.file_path,
expected_result.line_number.unwrap(),
expected_result.text
);
let file_type_string = String::from("js");
let mut args = common::make_args(query, Some(file_path), Some(file_type_string));
args.line_number = true;
args.no_color = true;
let actual = common::do_search(args);
for result in actual {
assert_eq!(expected, result.to_grep());
}
}

#[rstest]
fn search_returns_matching_js_function_line_with_two_files() {
let file_path = format!(
Expand Down

0 comments on commit bc4fdb9

Please sign in to comment.