test: add a regression test for Issue 14409

Signed-off-by: hi-rustin <29879298+hi-rustin@users.noreply.github.com>
This commit is contained in:
hi-rustin 2024-08-20 23:24:08 +08:00
parent c956e9f41c
commit 90b7387db5
12 changed files with 152 additions and 0 deletions

View File

@ -28,6 +28,7 @@ mod within_ws;
mod within_ws_and_pick_ws_package;
mod within_ws_with_alternative_registry;
mod within_ws_without_lockfile;
mod without_requiring_registry_auth;
// Initialize the registry without a token.
// Otherwise, it will try to list owners of the crate and fail.

View File

@ -0,0 +1,2 @@
[registry]
global-credential-providers = ["false"]

View File

@ -0,0 +1,16 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "cargo-list-test-fixture"
version = "0.0.0"
dependencies = [
"my-package",
]
[[package]]
name = "my-package"
version = "0.1.1+my-package"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21c0013931e013e890da011e601d9e8514359837da12125e7e89157d9349dcb7"

View File

@ -0,0 +1,8 @@
[workspace]
[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
[dependencies]
my-package = "0.1"

View File

@ -0,0 +1,26 @@
use cargo_test_support::prelude::*;
use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
use super::init_registry_without_token;
#[cargo_test]
fn case() {
init_registry_without_token();
cargo_test_support::registry::Package::new("my-package", "0.1.1+my-package").publish();
let project = Project::from_template(current_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
snapbox::cmd::Command::cargo_ui()
.arg("info")
.arg("my-package")
.arg("--registry=dummy-registry")
.current_dir(cwd)
.assert()
.success()
.stdout_eq(file!["stdout.term.svg"])
.stderr_eq(file!["stderr.term.svg"]);
assert_ui().subset_matches(current_dir!().join("out"), &project_root);
}

View File

@ -0,0 +1,2 @@
[registry]
global-credential-providers = ["false"]

View File

@ -0,0 +1,16 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "cargo-list-test-fixture"
version = "0.0.0"
dependencies = [
"my-package",
]
[[package]]
name = "my-package"
version = "0.1.1+my-package"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21c0013931e013e890da011e601d9e8514359837da12125e7e89157d9349dcb7"

View File

@ -0,0 +1,8 @@
[workspace]
[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
[dependencies]
my-package = "0.1"

View File

@ -0,0 +1,31 @@
<svg width="740px" height="92px" xmlns="http://www.w3.org/2000/svg">
<style>
.fg { fill: #AAAAAA }
.bg { background: #000000 }
.fg-green { fill: #00AA00 }
.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-green bold"> Updating</tspan><tspan> `dummy-registry` index</tspan>
</tspan>
<tspan x="10px" y="46px"><tspan class="fg-green bold"> Downloading</tspan><tspan> crates ...</tspan>
</tspan>
<tspan x="10px" y="64px"><tspan class="fg-green bold"> Downloaded</tspan><tspan> my-package v0.1.1+my-package (registry `dummy-registry`)</tspan>
</tspan>
<tspan x="10px" y="82px">
</tspan>
</text>
</svg>

After

Width:  |  Height:  |  Size: 1003 B

View File

@ -0,0 +1,42 @@
<svg width="911px" height="164px" xmlns="http://www.w3.org/2000/svg">
<style>
.fg { fill: #AAAAAA }
.bg { background: #000000 }
.fg-cyan { fill: #00AAAA }
.fg-green { fill: #00AA00 }
.fg-red { fill: #AA0000 }
.fg-yellow { fill: #AA5500 }
.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-green bold">my-package</tspan>
</tspan>
<tspan x="10px" y="46px"><tspan class="fg-green bold">version:</tspan><tspan> 0.1.1+my-package</tspan>
</tspan>
<tspan x="10px" y="64px"><tspan class="fg-green bold">license:</tspan><tspan> </tspan><tspan class="fg-red bold">unknown</tspan>
</tspan>
<tspan x="10px" y="82px"><tspan class="fg-green bold">rust-version:</tspan><tspan> </tspan><tspan class="fg-yellow bold">unknown</tspan>
</tspan>
<tspan x="10px" y="100px"><tspan class="fg-green bold">documentation:</tspan><tspan> https://docs.rs/my-package/0.1.1+my-package</tspan>
</tspan>
<tspan x="10px" y="118px"><tspan class="fg-green bold">crates.io:</tspan><tspan> https://crates.io/crates/my-package/0.1.1+my-package</tspan>
</tspan>
<tspan x="10px" y="136px"><tspan class="fg-cyan bold">note</tspan><tspan class="bold">:</tspan><tspan> to see how you depend on my-package, run `</tspan><tspan class="fg-cyan bold">cargo tree --invert --package my-package@0.1.1+my-package</tspan><tspan>`</tspan>
</tspan>
<tspan x="10px" y="154px">
</tspan>
</text>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB