@@ -6,28 +6,55 @@ use cargo_test_support::paths::CargoPathExt;
66use cargo_test_support:: project;
77use cargo_test_support:: registry:: { self , api_path, registry_url} ;
88
9- fn setup ( name : & str ) {
9+ fn setup ( name : & str , content : Option < & str > ) {
1010 let dir = api_path ( ) . join ( format ! ( "api/v1/crates/{}" , name) ) ;
1111 dir. mkdir_p ( ) ;
12- fs:: write (
13- dir. join ( "owners" ) ,
14- r#"{
12+ match content {
13+ Some ( body) => {
14+ fs:: write ( dir. join ( "owners" ) , body) . unwrap ( ) ;
15+ }
16+ None => { }
17+ }
18+ }
19+
20+ #[ cargo_test]
21+ fn simple_list ( ) {
22+ registry:: init ( ) ;
23+ let content = r#"{
1524 "users": [
1625 {
1726 "id": 70,
1827 "login": "github:rust-lang:core",
1928 "name": "Core"
2029 }
2130 ]
22- }"# ,
23- )
24- . unwrap ( ) ;
31+ }"# ;
32+ setup ( "foo" , Some ( content) ) ;
33+
34+ let p = project ( )
35+ . file (
36+ "Cargo.toml" ,
37+ r#"
38+ [project]
39+ name = "foo"
40+ version = "0.0.1"
41+ authors = []
42+ license = "MIT"
43+ description = "foo"
44+ "# ,
45+ )
46+ . file ( "src/main.rs" , "fn main() {}" )
47+ . build ( ) ;
48+
49+ p. cargo ( "owner -l --index" )
50+ . arg ( registry_url ( ) . to_string ( ) )
51+ . run ( ) ;
2552}
2653
2754#[ cargo_test]
28- fn simple_list ( ) {
55+ fn simple_add ( ) {
2956 registry:: init ( ) ;
30- setup ( "foo" ) ;
57+ setup ( "foo" , None ) ;
3158
3259 let p = project ( )
3360 . file (
@@ -44,7 +71,46 @@ fn simple_list() {
4471 . file ( "src/main.rs" , "fn main() {}" )
4572 . build ( ) ;
4673
47- p. cargo ( "owner -l --index" )
74+ p. cargo ( "owner -a username --index" )
4875 . arg ( registry_url ( ) . to_string ( ) )
76+ . with_status ( 101 )
77+ . with_stderr (
78+ " Updating `[..]` index
79+ error: failed to invite owners to crate foo: EOF while parsing a value at line 1 column 0" ,
80+ )
81+ . run ( ) ;
82+ }
83+
84+ #[ cargo_test]
85+ fn simple_remove ( ) {
86+ registry:: init ( ) ;
87+ setup ( "foo" , None ) ;
88+
89+ let p = project ( )
90+ . file (
91+ "Cargo.toml" ,
92+ r#"
93+ [project]
94+ name = "foo"
95+ version = "0.0.1"
96+ authors = []
97+ license = "MIT"
98+ description = "foo"
99+ "# ,
100+ )
101+ . file ( "src/main.rs" , "fn main() {}" )
102+ . build ( ) ;
103+
104+ p. cargo ( "owner -r username --index" )
105+ . arg ( registry_url ( ) . to_string ( ) )
106+ . with_status ( 101 )
107+ . with_stderr (
108+ " Updating `[..]` index
109+ Owner removing [\" username\" ] from crate foo
110+ error: failed to remove owners from crate foo
111+
112+ Caused by:
113+ EOF while parsing a value at line 1 column 0" ,
114+ )
49115 . run ( ) ;
50116}
0 commit comments