@@ -130,6 +130,58 @@ You may press ctrl-c to skip waiting; the crate should be available shortly.
130
130
validate_upload_foo ( ) ;
131
131
}
132
132
133
+ #[ cargo_test]
134
+ fn duplicate_version ( ) {
135
+ let registry_dupl = RegistryBuilder :: new ( )
136
+ . http_api ( )
137
+ . http_index ( )
138
+ // test registry doesn't error on duplicate versions, we need to
139
+ . add_responder ( "/api/v1/crates/new" , move |_req, _server| Response {
140
+ code : 200 ,
141
+ headers : vec ! [ ] ,
142
+ body : br#"{"errors": [{"detail": "crate version `0.0.1` is already uploaded"}]}"#
143
+ . to_vec ( ) ,
144
+ } )
145
+ . build ( ) ;
146
+
147
+ let p = project ( )
148
+ . file (
149
+ "Cargo.toml" ,
150
+ r#"
151
+ [package]
152
+ name = "foo"
153
+ version = "0.0.1"
154
+ authors = []
155
+ license = "MIT"
156
+ description = "foo"
157
+ "# ,
158
+ )
159
+ . file ( "src/main.rs" , "fn main() {}" )
160
+ . build ( ) ;
161
+
162
+ p. cargo ( "publish" )
163
+ . replace_crates_io ( registry_dupl. index_url ( ) )
164
+ . with_status ( 101 )
165
+ . with_stderr_data ( str![ [ r#"
166
+ [UPDATING] crates.io index
167
+ [WARNING] manifest has no documentation, homepage or repository.
168
+ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
169
+ [PACKAGING] foo v0.0.1 ([ROOT]/foo)
170
+ [PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
171
+ [VERIFYING] foo v0.0.1 ([ROOT]/foo)
172
+ [WARNING] no edition set: defaulting to the 2015 edition while the latest is 2021
173
+ [COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1)
174
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
175
+ [UPLOADING] foo v0.0.1 ([ROOT]/foo)
176
+ [ERROR] failed to publish to registry at http://127.0.0.1:41463/
177
+
178
+ Caused by:
179
+ the remote server responded with an [ERROR] crate version `0.0.1` is already uploaded
180
+
181
+ "# ] ] )
182
+ . run ( ) ;
183
+ }
184
+
133
185
// Check that the `token` key works at the root instead of under a
134
186
// `[registry]` table.
135
187
#[ cargo_test]
0 commit comments