1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use super::*;
fn entry_points(patterns: &[&str]) -> EntryPoints {
let patterns: Vec<String> = patterns.iter().map(|p| p.to_string()).collect();
EntryPoints::new(&patterns).unwrap()
}
#[test]
fn command_line_tasks_are_entry_points_by_convention() {
let entry = entry_points(&[]);
assert!(entry.conventional(Path::new("shop/lib/mix/tasks/seed.ex")));
assert!(entry.conventional(Path::new("shop/management/commands/seed.py")));
assert!(entry.conventional(Path::new("scripts/seed.ts")));
assert!(entry.conventional(Path::new("tools/bin/seed.js")));
}
#[test]
fn a_directory_that_only_shares_part_of_the_name_is_not_one() {
let entry = entry_points(&[]);
assert!(!entry.conventional(Path::new("shop/lib/shop/tasks/seed.ex")));
assert!(!entry.conventional(Path::new("shop/lib/mix/seed.ex")));
assert!(!entry.conventional(Path::new("shop/lib/shop/cart.ex")));
}
#[test]
fn a_file_named_like_the_directory_is_not_one() {
assert!(!entry_points(&[]).conventional(Path::new("shop/lib/scripts")));
}
#[test]
fn configured_globs_are_told_from_the_convention() {
let entry = entry_points(&["**/endpoint.ex"]);
assert!(entry.configured(Path::new("shop/lib/shop_web/endpoint.ex")));
assert!(!entry.conventional(Path::new("shop/lib/shop_web/endpoint.ex")));
assert!(!entry.configured(Path::new("scripts/seed.ts")));
assert!(!entry.configured(Path::new("shop/lib/shop_web/router.ex")));
}
#[test]
fn an_invalid_glob_names_the_key() {
let error = EntryPoints::new(&["a{".to_string()]).err().unwrap();
assert!(error.to_string().contains("[impact] entry_points"));
}