Skip to content

Commit b5be434

Browse files
fix broken tests - token_caching token_not_logged
1 parent d24d542 commit b5be434

File tree

4 files changed

+36
-22
lines changed

4 files changed

+36
-22
lines changed

src/cargo/ops/registry/publish.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
161161

162162
if !duplicate_query.is_empty() {
163163
bail!(
164-
"crate {} already has version {}. Aborting publish.",
164+
"crate {}@{} already exists on {}",
165165
pkg.name(),
166-
pkg.version()
166+
pkg.version(),
167+
source.describe()
167168
);
168169
}
169170

tests/testsuite/credential_process.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,31 @@ You may press ctrl-c [..]
544544
.with_stderr_data(output)
545545
.run();
546546

547+
let output_non_independent = r#"[UPDATING] `alternative` index
548+
{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"read"}
549+
[PACKAGING] foo v0.1.1 ([ROOT]/foo)
550+
[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
551+
{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"publish","name":"foo","vers":"0.1.1","cksum":"[..]"}
552+
[UPLOADING] foo v0.1.1 ([ROOT]/foo)
553+
[UPLOADED] foo v0.1.1 to registry `alternative`
554+
[NOTE] waiting [..]
555+
You may press ctrl-c [..]
556+
[PUBLISHED] foo v0.1.1 at registry `alternative`
557+
"#;
558+
559+
p.change_file(
560+
"Cargo.toml",
561+
r#"
562+
[package]
563+
name = "foo"
564+
version = "0.1.1"
565+
edition = "2015"
566+
description = "foo"
567+
license = "MIT"
568+
homepage = "https://example.com/"
569+
"#,
570+
);
571+
547572
p.change_file(
548573
".cargo/config.toml",
549574
&format!(
@@ -557,7 +582,7 @@ You may press ctrl-c [..]
557582
);
558583

559584
p.cargo("publish --registry alternative --no-verify")
560-
.with_stderr_data(output)
585+
.with_stderr_data(output_non_independent)
561586
.run();
562587
}
563588

tests/testsuite/publish.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,7 @@ You may press ctrl-c to skip waiting; the crate should be available shortly.
132132

133133
#[cargo_test]
134134
fn duplicate_version() {
135-
let arc: Arc<Mutex<u32>> = Arc::new(Mutex::new(0));
136-
let registry_dupl = RegistryBuilder::new()
137-
.http_api()
138-
.http_index()
139-
.add_responder("/index/3/f/foo", move |req, server| {
140-
let mut lock = arc.lock().unwrap();
141-
*lock += 1;
142-
if *lock <= 1 {
143-
server.not_found(req)
144-
} else {
145-
server.index(req)
146-
}
147-
})
148-
.build();
135+
let registry_dupl = RegistryBuilder::new().http_api().http_index().build();
149136

150137
let p = project()
151138
.file(
@@ -171,7 +158,7 @@ fn duplicate_version() {
171158
.replace_crates_io(registry_dupl.index_url())
172159
.with_stderr_data(str![[r#"
173160
[UPDATING] crates.io index
174-
[ERROR] crate foo already has version 0.0.1. Aborting publish.
161+
[ERROR] crate foo@0.0.1 already exists on [..]
175162
176163
"#]])
177164
.with_status(101)

tests/testsuite/registry_auth.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,10 @@ fn token_not_logged() {
565565
// 2. config.json again for verification
566566
// 3. /index/3/b/bar
567567
// 4. /dl/bar/1.0.0/download
568-
// 5. /api/v1/crates/new
569-
// 6. config.json for the "wait for publish"
570-
// 7. /index/3/f/foo for the "wait for publish"
571-
assert_eq!(authorizations.len(), 7);
568+
// 5. /index/3/f/foo for checking duplicate version
569+
// 6. /api/v1/crates/new
570+
// 7. config.json for the "wait for publish"
571+
// 8. /index/3/f/foo for the "wait for publish"
572+
assert_eq!(authorizations.len(), 8);
572573
assert!(!log.contains("a-unique_token"));
573574
}

0 commit comments

Comments
 (0)