Skip to content

Commit cd27a11

Browse files
committed
test(yank): Added test cases for bad version & prefixed v in version
1 parent 9ae361a commit cd27a11

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

tests/testsuite/yank.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,73 @@ fn inline_and_explicit_version() {
212212
"#]])
213213
.run();
214214
}
215+
216+
#[cargo_test]
217+
fn bad_version() {
218+
let registry = registry::init();
219+
setup("foo", "0.0.1");
220+
221+
let p = project()
222+
.file(
223+
"Cargo.toml",
224+
r#"
225+
[package]
226+
name = "foo"
227+
version = "0.0.1"
228+
authors = []
229+
license = "MIT"
230+
description = "foo"
231+
"#,
232+
)
233+
.file("src/main.rs", "fn main() {}")
234+
.build();
235+
236+
p.cargo("yank foo@bar")
237+
.replace_crates_io(registry.index_url())
238+
.with_status(101)
239+
.with_stderr_data(str![[r#"
240+
[UPDATING] crates.io index
241+
[YANK] foo@bar
242+
[ERROR] failed to yank from the registry at [ROOTURL]/api
243+
244+
Caused by:
245+
[37] Couldn't read a file:// file (Couldn't open file [ROOT]/api/api/v1/crates/foo/bar/yank)
246+
247+
"#]])
248+
.run();
249+
}
250+
251+
#[cargo_test]
252+
fn prefixed_v_in_version() {
253+
let registry = registry::init();
254+
setup("foo", "0.0.1");
255+
256+
let p = project()
257+
.file(
258+
"Cargo.toml",
259+
r#"
260+
[package]
261+
name = "foo"
262+
version = "0.0.1"
263+
authors = []
264+
license = "MIT"
265+
description = "foo"
266+
"#,
267+
)
268+
.file("src/main.rs", "fn main() {}")
269+
.build();
270+
271+
p.cargo("yank [email protected]")
272+
.replace_crates_io(registry.index_url())
273+
.with_status(101)
274+
.with_stderr_data(str![[r#"
275+
[UPDATING] crates.io index
276+
277+
[ERROR] failed to yank from the registry at [ROOTURL]/api
278+
279+
Caused by:
280+
[37] Couldn't read a file:// file (Couldn't open file [ROOT]/api/api/v1/crates/bar/v0.0.1/yank)
281+
282+
"#]])
283+
.run();
284+
}

0 commit comments

Comments
 (0)