Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

fix: bail out an error for non remote registry #64

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/ops/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ pub fn info(
package_id = None;
}

if !source_ids.original.is_remote_registry() {
anyhow::bail!("`cargo info` command currently only supports remote registry");
}

query_and_pretty_view(spec, package_id, config, registry, source_ids)
}

Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/cargo_information/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod with_locked_within_ws;
mod with_offline;
mod with_quiet;
mod within_ws;
mod within_ws_and_pick_ws_package;
mod within_ws_with_alternative_registry;

// Invoke `cargo-info info` with the test environment.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[workspace]

[package]
name = "cargo-list-test-fixture"
version = "0.2.0"

[dependencies]
my-package = "0.1"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use cargo_test_macro::cargo_test;
use cargo_test_support::{compare::assert_ui, curr_dir, Project};

use super::{cargo_info, 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();
cargo_test_support::registry::Package::new("cargo-list-test-fixture", "0.1.1+my-package")
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

cargo_info()
.arg("cargo-list-test-fixture")
.current_dir(cwd)
.assert()
.failure()
.stdout_matches_path(curr_dir!().join("stdout.log"))
.stderr_matches_path(curr_dir!().join("stderr.log"));

assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[workspace]

[package]
name = "cargo-list-test-fixture"
version = "0.2.0"

[dependencies]
my-package = "0.1"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error: `cargo info` command currently only supports remote registry