Skip to content

Commit

Permalink
Add check token before verify tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Helfet committed Apr 16, 2019
1 parent d9bc8c0 commit f7c424f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/testsuite/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,3 +977,39 @@ fn publish_with_patch() {
&["Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
);
}

#[test]
fn publish_checks_for_token_before_verify() {
registry::init();

let p = project()
.file(
"Cargo.toml",
r#"
[project]
name = "foo"
version = "0.0.1"
authors = []
license = "MIT"
description = "foo"
"#,
)
.file("src/main.rs", "fn main() {}")
.build();

let credentials = paths::home().join(".cargo/credentials");
fs::remove_file(&credentials).unwrap();

// Assert upload token error before the package is verified
p.cargo("publish")
.with_status(101)
.with_stderr_contains("[ERROR] no upload token found, please run `cargo login`")
.with_stderr_does_not_contain("[VERIFYING] foo v0.0.1 ([CWD])")
.run();

// Assert package verified successfully on dry run
p.cargo("publish --dry-run")
.with_status(0)
.with_stderr_contains("[VERIFYING] foo v0.0.1 ([CWD])")
.run();
}

0 comments on commit f7c424f

Please sign in to comment.