Skip to content

Commit d103edc

Browse files
committed
refactor(tests): Publish using a real registry
1 parent 8e2a760 commit d103edc

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
@@ -85,20 +85,6 @@ fn validate_upload_li() {
8585
);
8686
}
8787

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

153140
let p = project()
154141
.file(
@@ -193,12 +180,14 @@ See [..]
193180
)
194181
.run();
195182

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

199187
#[cargo_test]
200188
fn simple_with_index() {
201-
let registry = registry::init();
189+
// `publish` generally requires a remote registry
190+
let registry = registry::RegistryBuilder::new().http_api().build();
202191

203192
let p = project()
204193
.file(
@@ -230,7 +219,8 @@ fn simple_with_index() {
230219
)
231220
.run();
232221

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

236226
#[cargo_test]
@@ -388,7 +378,8 @@ to proceed despite this and include the uncommitted changes, pass the `--allow-d
388378

389379
#[cargo_test]
390380
fn publish_clean() {
391-
let registry = registry::init();
381+
// `publish` generally requires a remote registry
382+
let registry = registry::RegistryBuilder::new().http_api().build();
392383

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

@@ -423,12 +414,14 @@ fn publish_clean() {
423414
)
424415
.run();
425416

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

429421
#[cargo_test]
430422
fn publish_in_sub_repo() {
431-
let registry = registry::init();
423+
// `publish` generally requires a remote registry
424+
let registry = registry::RegistryBuilder::new().http_api().build();
432425

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

@@ -464,12 +457,14 @@ fn publish_in_sub_repo() {
464457
)
465458
.run();
466459

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

470464
#[cargo_test]
471465
fn publish_when_ignored() {
472-
let registry = registry::init();
466+
// `publish` generally requires a remote registry
467+
let registry = registry::RegistryBuilder::new().http_api().build();
473468

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

@@ -505,23 +500,14 @@ fn publish_when_ignored() {
505500
)
506501
.run();
507502

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

522507
#[cargo_test]
523508
fn ignore_when_crate_ignored() {
524-
let registry = registry::init();
509+
// `publish` generally requires a remote registry
510+
let registry = registry::RegistryBuilder::new().http_api().build();
525511

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

@@ -556,17 +542,8 @@ fn ignore_when_crate_ignored() {
556542
)
557543
.run();
558544

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

572549
#[cargo_test]
@@ -895,7 +872,8 @@ The registry `alternative` is not listed in the `publish` value in Cargo.toml.
895872
// Explicitly setting `crates-io` in the publish list.
896873
#[cargo_test]
897874
fn publish_with_crates_io_explicit() {
898-
let registry = registry::init();
875+
// `publish` generally requires a remote registry
876+
let registry = registry::RegistryBuilder::new().http_api().build();
899877

900878
let p = project()
901879
.file(
@@ -941,7 +919,8 @@ The registry `alternative` is not listed in the `publish` value in Cargo.toml.
941919

942920
#[cargo_test]
943921
fn publish_with_select_features() {
944-
let registry = registry::init();
922+
// `publish` generally requires a remote registry
923+
let registry = registry::RegistryBuilder::new().http_api().build();
945924

946925
let p = project()
947926
.file(
@@ -986,7 +965,8 @@ fn publish_with_select_features() {
986965

987966
#[cargo_test]
988967
fn publish_with_all_features() {
989-
let registry = registry::init();
968+
// `publish` generally requires a remote registry
969+
let registry = registry::RegistryBuilder::new().http_api().build();
990970

991971
let p = project()
992972
.file(
@@ -1515,7 +1495,8 @@ repository = "foo"
15151495

15161496
#[cargo_test]
15171497
fn credentials_ambiguous_filename() {
1518-
let registry = registry::init();
1498+
// `publish` generally requires a remote registry
1499+
let registry = registry::RegistryBuilder::new().http_api().build();
15191500

15201501
let credentials_toml = paths::home().join(".cargo/credentials.toml");
15211502
fs::write(credentials_toml, r#"token = "api-token""#).unwrap();
@@ -1548,8 +1529,6 @@ fn credentials_ambiguous_filename() {
15481529
",
15491530
)
15501531
.run();
1551-
1552-
validate_upload_foo();
15531532
}
15541533

15551534
// --index will not load registry.token to avoid possibly leaking
@@ -2105,7 +2084,8 @@ fn in_virtual_workspace() {
21052084

21062085
#[cargo_test]
21072086
fn in_virtual_workspace_with_p() {
2108-
let registry = registry::init();
2087+
// `publish` generally requires a remote registry
2088+
let registry = registry::RegistryBuilder::new().http_api().build();
21092089

21102090
let p = project()
21112091
.file(

0 commit comments

Comments
 (0)