Skip to content

Commit ee7aa28

Browse files
committed
refactor(tests): Publish using a real registry
1 parent 262ab4e commit ee7aa28

File tree

2 files changed

+36
-55
lines changed

2 files changed

+36
-55
lines changed

tests/testsuite/cross_publish.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ fn publish_with_target() {
6666
return;
6767
}
6868

69-
let registry = registry::init();
69+
// `publish` generally requires a remote registry
70+
let registry = registry::RegistryBuilder::new().http_api().build();
7071

7172
let p = project()
7273
.file(

tests/testsuite/publish.rs

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,6 @@ fn validate_upload_li() {
8484
);
8585
}
8686

87-
fn validate_upload_foo_clean() {
88-
publish::validate_upload(
89-
CLEAN_FOO_JSON,
90-
"foo-0.0.1.crate",
91-
&[
92-
"Cargo.lock",
93-
"Cargo.toml",
94-
"Cargo.toml.orig",
95-
"src/main.rs",
96-
".cargo_vcs_info.json",
97-
],
98-
);
99-
}
100-
10187
#[cargo_test]
10288
fn simple() {
10389
// HACK below allows us to use a local registry
@@ -147,7 +133,8 @@ See [..]
147133
// `[registry]` table.
148134
#[cargo_test]
149135
fn old_token_location() {
150-
let registry = registry::init();
136+
// `publish` generally requires a remote registry
137+
let registry = registry::RegistryBuilder::new().http_api().build();
151138

152139
let p = project()
153140
.file(
@@ -192,12 +179,14 @@ See [..]
192179
)
193180
.run();
194181

195-
validate_upload_foo();
182+
// Skip `validate_upload_foo` as we just cared we got far enough for verify the token behavior.
183+
// Other tests will verify the endpoint gets the right payload.
196184
}
197185

198186
#[cargo_test]
199187
fn simple_with_index() {
200-
let registry = registry::init();
188+
// `publish` generally requires a remote registry
189+
let registry = registry::RegistryBuilder::new().http_api().build();
201190

202191
let p = project()
203192
.file(
@@ -229,7 +218,8 @@ fn simple_with_index() {
229218
)
230219
.run();
231220

232-
validate_upload_foo();
221+
// Skip `validate_upload_foo` as we just cared we got far enough for verify the VCS behavior.
222+
// Other tests will verify the endpoint gets the right payload.
233223
}
234224

235225
#[cargo_test]
@@ -387,7 +377,8 @@ to proceed despite this and include the uncommitted changes, pass the `--allow-d
387377

388378
#[cargo_test]
389379
fn publish_clean() {
390-
let registry = registry::init();
380+
// `publish` generally requires a remote registry
381+
let registry = registry::RegistryBuilder::new().http_api().build();
391382

392383
let p = project().build();
393384

@@ -422,12 +413,14 @@ fn publish_clean() {
422413
)
423414
.run();
424415

425-
validate_upload_foo_clean();
416+
// Skip `validate_upload_foo_clean` as we just cared we got far enough for verify the VCS behavior.
417+
// Other tests will verify the endpoint gets the right payload.
426418
}
427419

428420
#[cargo_test]
429421
fn publish_in_sub_repo() {
430-
let registry = registry::init();
422+
// `publish` generally requires a remote registry
423+
let registry = registry::RegistryBuilder::new().http_api().build();
431424

432425
let p = project().no_manifest().file("baz", "").build();
433426

@@ -463,12 +456,14 @@ fn publish_in_sub_repo() {
463456
)
464457
.run();
465458

466-
validate_upload_foo_clean();
459+
// Skip `validate_upload_foo_clean` as we just cared we got far enough for verify the VCS behavior.
460+
// Other tests will verify the endpoint gets the right payload.
467461
}
468462

469463
#[cargo_test]
470464
fn publish_when_ignored() {
471-
let registry = registry::init();
465+
// `publish` generally requires a remote registry
466+
let registry = registry::RegistryBuilder::new().http_api().build();
472467

473468
let p = project().file("baz", "").build();
474469

@@ -504,23 +499,14 @@ fn publish_when_ignored() {
504499
)
505500
.run();
506501

507-
publish::validate_upload(
508-
CLEAN_FOO_JSON,
509-
"foo-0.0.1.crate",
510-
&[
511-
"Cargo.lock",
512-
"Cargo.toml",
513-
"Cargo.toml.orig",
514-
"src/main.rs",
515-
".gitignore",
516-
".cargo_vcs_info.json",
517-
],
518-
);
502+
// Skip `validate_upload` as we just cared we got far enough for verify the VCS behavior.
503+
// Other tests will verify the endpoint gets the right payload.
519504
}
520505

521506
#[cargo_test]
522507
fn ignore_when_crate_ignored() {
523-
let registry = registry::init();
508+
// `publish` generally requires a remote registry
509+
let registry = registry::RegistryBuilder::new().http_api().build();
524510

525511
let p = project().no_manifest().file("bar/baz", "").build();
526512

@@ -555,17 +541,8 @@ fn ignore_when_crate_ignored() {
555541
)
556542
.run();
557543

558-
publish::validate_upload(
559-
CLEAN_FOO_JSON,
560-
"foo-0.0.1.crate",
561-
&[
562-
"Cargo.lock",
563-
"Cargo.toml",
564-
"Cargo.toml.orig",
565-
"src/main.rs",
566-
"baz",
567-
],
568-
);
544+
// Skip `validate_upload` as we just cared we got far enough for verify the VCS behavior.
545+
// Other tests will verify the endpoint gets the right payload.
569546
}
570547

571548
#[cargo_test]
@@ -894,7 +871,8 @@ The registry `alternative` is not listed in the `publish` value in Cargo.toml.
894871
// Explicitly setting `crates-io` in the publish list.
895872
#[cargo_test]
896873
fn publish_with_crates_io_explicit() {
897-
let registry = registry::init();
874+
// `publish` generally requires a remote registry
875+
let registry = registry::RegistryBuilder::new().http_api().build();
898876

899877
let p = project()
900878
.file(
@@ -940,7 +918,8 @@ The registry `alternative` is not listed in the `publish` value in Cargo.toml.
940918

941919
#[cargo_test]
942920
fn publish_with_select_features() {
943-
let registry = registry::init();
921+
// `publish` generally requires a remote registry
922+
let registry = registry::RegistryBuilder::new().http_api().build();
944923

945924
let p = project()
946925
.file(
@@ -985,7 +964,8 @@ fn publish_with_select_features() {
985964

986965
#[cargo_test]
987966
fn publish_with_all_features() {
988-
let registry = registry::init();
967+
// `publish` generally requires a remote registry
968+
let registry = registry::RegistryBuilder::new().http_api().build();
989969

990970
let p = project()
991971
.file(
@@ -1514,7 +1494,8 @@ repository = "foo"
15141494

15151495
#[cargo_test]
15161496
fn credentials_ambiguous_filename() {
1517-
let registry = registry::init();
1497+
// `publish` generally requires a remote registry
1498+
let registry = registry::RegistryBuilder::new().http_api().build();
15181499

15191500
let credentials_toml = paths::home().join(".cargo/credentials.toml");
15201501
fs::write(credentials_toml, r#"token = "api-token""#).unwrap();
@@ -1547,8 +1528,6 @@ fn credentials_ambiguous_filename() {
15471528
",
15481529
)
15491530
.run();
1550-
1551-
validate_upload_foo();
15521531
}
15531532

15541533
// --index will not load registry.token to avoid possibly leaking
@@ -2104,7 +2083,8 @@ fn in_virtual_workspace() {
21042083

21052084
#[cargo_test]
21062085
fn in_virtual_workspace_with_p() {
2107-
let registry = registry::init();
2086+
// `publish` generally requires a remote registry
2087+
let registry = registry::RegistryBuilder::new().http_api().build();
21082088

21092089
let p = project()
21102090
.file(

0 commit comments

Comments
 (0)