Skip to content

Commit 6de33f0

Browse files
committed
Auto merge of #7818 - giraffate:add_some_tests, r=alexcrichton
Add tests for `cargo owner -a/-r` / `cargo yank --undo` Follow up 5e15286. There were no tests for `cargo owner -a/-r` and `cargo yank --undo`. However, These commands in tests had empty response. So I also update response handling with reference to 7dd0f93.
2 parents 8ee3d92 + a492cfc commit 6de33f0

File tree

2 files changed

+89
-10
lines changed

2 files changed

+89
-10
lines changed

tests/testsuite/owner.rs

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,55 @@ use cargo_test_support::paths::CargoPathExt;
66
use cargo_test_support::project;
77
use 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
}

tests/testsuite/yank.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,17 @@ fn simple() {
3535
p.cargo("yank --vers 0.0.1 --index")
3636
.arg(registry_url().to_string())
3737
.run();
38+
39+
p.cargo("yank --undo --vers 0.0.1 --index")
40+
.arg(registry_url().to_string())
41+
.with_status(101)
42+
.with_stderr(
43+
" Updating `[..]` index
44+
Unyank foo:0.0.1
45+
error: failed to undo a yank
46+
47+
Caused by:
48+
EOF while parsing a value at line 1 column 0",
49+
)
50+
.run();
3851
}

0 commit comments

Comments
 (0)