@@ -18,8 +18,8 @@ fn assert_check_unused_dependencies(cmd: &str) -> Result<(), Box<dyn Error>> {
18
18
"packs/foo depends on packs/bar but does not use it" ,
19
19
) )
20
20
. stderr ( predicate:: str:: contains (
21
- format ! ( "Error: Found 3 unnecessary dependencies. Run `packs {}| --auto-correct` to remove them." , & cmd ) ,
22
- ) ) ;
21
+ "Error: Found 3 unused dependencies. Run `packs check-unused-dependencies --auto-correct` to remove them." )
22
+ ) ;
23
23
Ok ( ( ) )
24
24
}
25
25
@@ -33,8 +33,24 @@ fn test_check_unused_dependencies() -> Result<(), Box<dyn Error>> {
33
33
assert_check_unused_dependencies ( "check-unused-dependencies" )
34
34
}
35
35
36
+ fn assert_auto_correct_unused_dependencies (
37
+ cmd : & str ,
38
+ flag : & str ,
39
+ ) -> Result < ( ) , Box < dyn Error > > {
40
+ common:: set_up_fixtures ( ) ;
41
+
42
+ let expected_before_autocorrect = [
43
+ "enforce_dependencies: true" ,
44
+ "enforce_privacy: true" ,
45
+ "layer: technical_services" ,
46
+ "dependencies:" ,
47
+ "- packs/bar" ,
48
+ "- packs/baz\n " ,
49
+ ]
50
+ . join ( "\n " ) ;
51
+ let foo_package_yml = fs:: read_to_string ( "tests/fixtures/app_with_unnecessary_dependencies/packs/foo/package.yml" ) . unwrap ( ) ;
52
+ assert_eq ! ( foo_package_yml, expected_before_autocorrect) ;
36
53
37
- fn assert_auto_correct_unused_dependencies ( cmd : & str , flag : & str ) -> Result < ( ) , Box < dyn Error > > {
38
54
Command :: cargo_bin ( "pks" ) ?
39
55
. arg ( "--project-root" )
40
56
. arg ( "tests/fixtures/app_with_unnecessary_dependencies" )
@@ -60,10 +76,19 @@ fn assert_auto_correct_unused_dependencies(cmd: &str, flag: &str) -> Result<(),
60
76
61
77
#[ test]
62
78
fn test_auto_correct_unnecessary_dependencies ( ) -> Result < ( ) , Box < dyn Error > > {
63
- assert_auto_correct_unused_dependencies ( "check-unused-dependencies" , "--auto-correct" ) ?;
79
+ assert_auto_correct_unused_dependencies (
80
+ "check-unused-dependencies" ,
81
+ "--auto-correct" ,
82
+ ) ?;
64
83
assert_auto_correct_unused_dependencies ( "check-unused-dependencies" , "-a" ) ?;
65
- assert_auto_correct_unused_dependencies ( "check-unnecessary-dependencies" , "-a" ) ?;
66
- assert_auto_correct_unused_dependencies ( "check-unnecessary-dependencies" , "--auto-correct" )
84
+ assert_auto_correct_unused_dependencies (
85
+ "check-unnecessary-dependencies" ,
86
+ "-a" ,
87
+ ) ?;
88
+ assert_auto_correct_unused_dependencies (
89
+ "check-unnecessary-dependencies" ,
90
+ "--auto-correct" ,
91
+ )
67
92
}
68
93
69
94
#[ test]
0 commit comments