test(add): Added test case for prefixed v in version

This commit is contained in:
Pyrode 2025-05-03 22:22:06 +05:30
parent 7e09951039
commit ac86dea366
5 changed files with 67 additions and 0 deletions

View File

@ -126,6 +126,7 @@ mod path_base_unstable;
mod path_dev;
mod path_inferred_name;
mod path_inferred_name_conflicts_full_feature;
mod prefixed_v_in_version;
mod preserve_dep_std_table;
mod preserve_features_sorted;
mod preserve_features_table;

View File

@ -0,0 +1 @@
../add-basic.in

View File

@ -0,0 +1,26 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::Project;
#[cargo_test]
fn case() {
cargo_test_support::registry::init();
let project = Project::from_template(current_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
snapbox::cmd::Command::cargo_ui()
.arg("add")
.arg_line("foo@v0.0.1")
.current_dir(cwd)
.assert()
.code(101)
.stdout_eq(str![""])
.stderr_eq(file!["stderr.term.svg"]);
assert_ui().subset_matches(current_dir!().join("out"), &project_root);
}

View File

@ -0,0 +1,6 @@
[workspace]
[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
edition = "2015"

View File

@ -0,0 +1,33 @@
<svg width="740px" height="110px" xmlns="http://www.w3.org/2000/svg">
<style>
.fg { fill: #AAAAAA }
.bg { background: #000000 }
.fg-red { fill: #AA0000 }
.container {
padding: 0 10px;
line-height: 18px;
}
.bold { font-weight: bold; }
tspan {
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
white-space: pre;
line-height: 18px;
}
</style>
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
<text xml:space="preserve" class="container fg">
<tspan x="10px" y="28px"><tspan class="fg-red bold">error</tspan><tspan class="bold">:</tspan><tspan> invalid version requirement `v0.0.1`</tspan>
</tspan>
<tspan x="10px" y="46px">
</tspan>
<tspan x="10px" y="64px"><tspan>Caused by:</tspan>
</tspan>
<tspan x="10px" y="82px"><tspan> unexpected character 'v' while parsing major version number</tspan>
</tspan>
<tspan x="10px" y="100px">
</tspan>
</text>
</svg>

After

Width:  |  Height:  |  Size: 981 B