refactor: Reorganise integration tests (#9282)

This commit reorganises cli/tests/integration_tests.rs.

All integration tests had been moved into integration module,
which allows to run only integration tests by "cargo test integration".

Additionally some tests were further grouped under nested modules
like "inspector", "file_watcher" or "repl".
This commit is contained in:
Bartek Iwańczuk 2021-02-01 19:09:25 +01:00 committed by GitHub
parent 84f8b87f1b
commit a2b5d44f1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5115 additions and 5088 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1558,6 +1558,70 @@ mod tests {
}
}
#[test]
fn test_pattern_match() {
// foo, bar, baz, qux, quux, quuz, corge, grault, garply, waldo, fred, plugh, xyzzy
let wildcard = "[BAR]";
assert!(pattern_match("foo[BAR]baz", "foobarbaz", wildcard));
assert!(!pattern_match("foo[BAR]baz", "foobazbar", wildcard));
let multiline_pattern = "[BAR]
foo:
[BAR]baz[BAR]";
fn multi_line_builder(input: &str, leading_text: Option<&str>) -> String {
// If there is leading text add a newline so it's on it's own line
let head = match leading_text {
Some(v) => format!("{}\n", v),
None => "".to_string(),
};
format!(
"{}foo:
quuz {} corge
grault",
head, input
)
}
// Validate multi-line string builder
assert_eq!(
"QUUX=qux
foo:
quuz BAZ corge
grault",
multi_line_builder("BAZ", Some("QUUX=qux"))
);
// Correct input & leading line
assert!(pattern_match(
multiline_pattern,
&multi_line_builder("baz", Some("QUX=quux")),
wildcard
));
// Correct input & no leading line
assert!(pattern_match(
multiline_pattern,
&multi_line_builder("baz", None),
wildcard
));
// Incorrect input & leading line
assert!(!pattern_match(
multiline_pattern,
&multi_line_builder("garply", Some("QUX=quux")),
wildcard
));
// Incorrect input & no leading line
assert!(!pattern_match(
multiline_pattern,
&multi_line_builder("garply", None),
wildcard
));
}
#[test]
fn max_mem_parse() {
const TEXT: &str = include_str!("./testdata/time.out");