Skip to content

Commit 0eba08c

Browse files
stupendoussuperpowerstorhovland
authored andcommitted
add test | publishing existing version
1 parent 11dccd1 commit 0eba08c

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
@@ -130,6 +130,57 @@ You may press ctrl-c to skip waiting; the crate should be available shortly.
130130
validate_upload_foo();
131131
}
132132

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

0 commit comments

Comments
 (0)