Skip to content

Commit 4a2480e

Browse files
add test | publishing existing version
1 parent c21dd51 commit 4a2480e

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

tests/testsuite/publish.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,57 @@ You may press ctrl-c to skip waiting; the crate should be available shortly.
128128
validate_upload_foo();
129129
}
130130

131+
#[cargo_test]
132+
fn duplicate_version() {
133+
let registry_dupl = RegistryBuilder::new()
134+
.http_api()
135+
.http_index()
136+
.add_responder("/api/v1/crates/new", move |_req, _server| Response {
137+
code: 200,
138+
headers: vec![],
139+
body: br#"{"errors": [{"detail": "crate version `0.0.1` is already uploaded"}]}"#
140+
.to_vec(),
141+
})
142+
.build();
143+
144+
let p = project()
145+
.file(
146+
"Cargo.toml",
147+
r#"
148+
[package]
149+
name = "foo"
150+
version = "0.0.1"
151+
authors = []
152+
license = "MIT"
153+
description = "foo"
154+
"#,
155+
)
156+
.file("src/main.rs", "fn main() {}")
157+
.build();
158+
159+
p.cargo("publish")
160+
.replace_crates_io(registry_dupl.index_url())
161+
.with_stderr(
162+
"\
163+
[UPDATING] crates.io index
164+
[WARNING] [..]
165+
See [..]
166+
[PACKAGING] foo v0.0.1 ([CWD])
167+
[VERIFYING] foo v0.0.1 ([CWD])
168+
[..]
169+
[..]
170+
[..]
171+
[UPLOADING] foo v0.0.1 ([CWD])
172+
error: failed to publish [..]
173+
174+
Caused by:
175+
[..] is already uploaded
176+
",
177+
)
178+
.with_status(101)
179+
.run();
180+
}
181+
131182
// Check that the `token` key works at the root instead of under a
132183
// `[registry]` table.
133184
#[cargo_test]

0 commit comments

Comments
 (0)