Skip to content

Commit f7c424f

Browse files
author
Alex Helfet
committed
Add check token before verify tests.
1 parent d9bc8c0 commit f7c424f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/testsuite/publish.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,3 +977,39 @@ fn publish_with_patch() {
977977
&["Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
978978
);
979979
}
980+
981+
#[test]
982+
fn publish_checks_for_token_before_verify() {
983+
registry::init();
984+
985+
let p = project()
986+
.file(
987+
"Cargo.toml",
988+
r#"
989+
[project]
990+
name = "foo"
991+
version = "0.0.1"
992+
authors = []
993+
license = "MIT"
994+
description = "foo"
995+
"#,
996+
)
997+
.file("src/main.rs", "fn main() {}")
998+
.build();
999+
1000+
let credentials = paths::home().join(".cargo/credentials");
1001+
fs::remove_file(&credentials).unwrap();
1002+
1003+
// Assert upload token error before the package is verified
1004+
p.cargo("publish")
1005+
.with_status(101)
1006+
.with_stderr_contains("[ERROR] no upload token found, please run `cargo login`")
1007+
.with_stderr_does_not_contain("[VERIFYING] foo v0.0.1 ([CWD])")
1008+
.run();
1009+
1010+
// Assert package verified successfully on dry run
1011+
p.cargo("publish --dry-run")
1012+
.with_status(0)
1013+
.with_stderr_contains("[VERIFYING] foo v0.0.1 ([CWD])")
1014+
.run();
1015+
}

0 commit comments

Comments
 (0)