From b2a04aa5c8cc9c82b1cacdaa6e6e7d57573f5a7d Mon Sep 17 00:00:00 2001 From: Riccardo Attilio Galli Date: Thu, 28 Mar 2024 23:41:24 -0700 Subject: [PATCH] Test npm protocol in dependencies --- tests/cli.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/cli.rs b/tests/cli.rs index 39a4e06..6f392ad 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -12,6 +12,7 @@ __metadata: resolution: "foo@workspace:." dependencies: foolib: 1.2.3 || ^2.0.0 + buzz: "npm:^1.1.1" languageName: unknown linkType: soft @@ -21,6 +22,13 @@ __metadata: checksum: 123061e52a0b3792c6a0472bf48ca6c337ccb58e92261049e7727a12c326b9627537e2ef8cb4453354d02c763b87c8b516f4eedfad99945c308927285bbc12ba languageName: node linkType: hard + +"buzz@npm:^1.1.1": + version: 1.1.2 + resolution: "buzz@npm:1.1.2" + checksum: 58e92261049e7727a12c326b9627537e123061e52a0b3792c6a0472bf48ca6c337ccb2ef8cb4453354d02c763b87c8b516f4eedfad99945c308927285bbc12ba + languageName: node + linkType: hard "#; const YARN_LOCK_V6_ONLY_DIRECT_DEPS: &str = r#"# This file is generated by running "yarn install" inside your project. @@ -100,6 +108,22 @@ fn it_finds_a_package_without_range() { ); } +#[test] +fn it_finds_a_package_whose_dep_is_using_npm_protocol() { + let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + + let assert = cmd + .args(["buzz"]) + .write_stdin(YARN_LOCK_V6_WITH_DEPS) + .assert(); + + assert.success().stdout( + r#"└─ foo@. + └─ buzz@^1.1.1 +"#, + ); +} + #[test] fn it_finds_a_package_in_a_yarn_lock_with_only_direct_deps() { let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap();