Skip to content

Commit

Permalink
test: migrate yank to snapbox
Browse files Browse the repository at this point in the history
  • Loading branch information
eth3lbert committed Jun 21, 2024
1 parent 938cf10 commit 0ed9c9e
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions tests/testsuite/yank.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
//! Tests for the `cargo yank` command.

#![allow(deprecated)]

use std::fs;

use cargo_test_support::paths::CargoPathExt;
use cargo_test_support::project;
use cargo_test_support::registry;
use cargo_test_support::str;

fn setup(name: &str, version: &str) {
let dir = registry::api_path().join(format!("api/v1/crates/{}/{}", name, version));
Expand Down Expand Up @@ -41,14 +40,15 @@ fn explicit_version() {
p.cargo("yank --undo --version 0.0.1")
.replace_crates_io(registry.index_url())
.with_status(101)
.with_stderr(
" Updating crates.io index
.with_stderr_data(str![[r#"
[UPDATING] crates.io index
Unyank foo@0.0.1
error: failed to undo a yank from the registry at file:///[..]
[ERROR] failed to undo a yank from the registry at [ROOTURL]/api
Caused by:
EOF while parsing a value at line 1 column 0",
)
EOF while parsing a value at line 1 column 0
"#]])
.run();
}

Expand Down Expand Up @@ -117,14 +117,15 @@ fn inline_version() {
p.cargo("yank --undo foo@0.0.1")
.replace_crates_io(registry.index_url())
.with_status(101)
.with_stderr(
" Updating crates.io index
.with_stderr_data(str![[r#"
[UPDATING] crates.io index
Unyank foo@0.0.1
error: failed to undo a yank from the registry at file:///[..]
[ERROR] failed to undo a yank from the registry at [ROOTURL]/api
Caused by:
EOF while parsing a value at line 1 column 0",
)
EOF while parsing a value at line 1 column 0
"#]])
.run();
}

Expand All @@ -149,7 +150,10 @@ fn version_required() {

p.cargo("yank foo")
.with_status(101)
.with_stderr("error: `--version` is required")
.with_stderr_data(str![[r#"
[ERROR] `--version` is required
"#]])
.run();
}

Expand All @@ -174,7 +178,10 @@ fn inline_version_without_name() {

p.cargo("yank @0.0.1")
.with_status(101)
.with_stderr("error: missing crate name for `@0.0.1`")
.with_stderr_data(str![[r#"
[ERROR] missing crate name for `@0.0.1`
"#]])
.run();
}

Expand All @@ -199,6 +206,9 @@ fn inline_and_explicit_version() {

p.cargo("yank foo@0.0.1 --version 0.0.1")
.with_status(101)
.with_stderr("error: cannot specify both `@0.0.1` and `--version`")
.with_stderr_data(str![[r#"
[ERROR] cannot specify both `@0.0.1` and `--version`
"#]])
.run();
}

0 comments on commit 0ed9c9e

Please sign in to comment.