Skip to content

Commit e883054

Browse files
committed
test: verify publish failed with --index and the only implicit allowed registry
The message is misleading and shouldn't proceed when `--index` presents.
1 parent e57ce13 commit e883054

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/testsuite/publish.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,48 @@ You may press ctrl-c [..]
921921
);
922922
}
923923

924+
#[cargo_test]
925+
fn publish_failed_with_index_and_only_allowed_registry() {
926+
let registry = RegistryBuilder::new()
927+
.http_api()
928+
.http_index()
929+
.alternative()
930+
.build();
931+
932+
let p = project().build();
933+
934+
let _ = repo(&paths::root().join("foo"))
935+
.file(
936+
"Cargo.toml",
937+
r#"
938+
[package]
939+
name = "foo"
940+
version = "0.0.1"
941+
authors = []
942+
license = "MIT"
943+
description = "foo"
944+
documentation = "foo"
945+
homepage = "foo"
946+
repository = "foo"
947+
publish = ["alternative"]
948+
"#,
949+
)
950+
.file("src/main.rs", "fn main() {}")
951+
.build();
952+
953+
p.cargo("publish")
954+
.arg("--index")
955+
.arg(registry.index_url().as_str())
956+
.with_status(101)
957+
.with_stderr(
958+
"\
959+
[NOTE] Found `alternative` as only allowed registry. Publishing to it automatically.
960+
[ERROR] command-line argument --index requires --token to be specified
961+
",
962+
)
963+
.run();
964+
}
965+
924966
#[cargo_test]
925967
fn publish_fail_with_no_registry_specified() {
926968
let p = project().build();

0 commit comments

Comments
 (0)