@@ -6,28 +6,55 @@ use cargo_test_support::paths::CargoPathExt;
6
6
use cargo_test_support:: project;
7
7
use cargo_test_support:: registry:: { self , api_path, registry_url} ;
8
8
9
- fn setup ( name : & str ) {
9
+ fn setup ( name : & str , content : Option < & str > ) {
10
10
let dir = api_path ( ) . join ( format ! ( "api/v1/crates/{}" , name) ) ;
11
11
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#"{
15
24
"users": [
16
25
{
17
26
"id": 70,
18
27
"login": "github:rust-lang:core",
19
28
"name": "Core"
20
29
}
21
30
]
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 ( ) ;
25
52
}
26
53
27
54
#[ cargo_test]
28
- fn simple_list ( ) {
55
+ fn simple_add ( ) {
29
56
registry:: init ( ) ;
30
- setup ( "foo" ) ;
57
+ setup ( "foo" , None ) ;
31
58
32
59
let p = project ( )
33
60
. file (
@@ -44,7 +71,46 @@ fn simple_list() {
44
71
. file ( "src/main.rs" , "fn main() {}" )
45
72
. build ( ) ;
46
73
47
- p. cargo ( "owner -l --index" )
74
+ p. cargo ( "owner -a username --index" )
48
75
. 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
+ )
49
115
. run ( ) ;
50
116
}
0 commit comments