From 15f5f74eb745915e68b3bc16b9ec048b94e26b97 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Fri, 1 Mar 2024 21:34:13 +0000 Subject: feat(unstable/pm): support version contraints in 'deno add' (#22646) --- tests/integration/pm_tests.rs | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/integration/pm_tests.rs b/tests/integration/pm_tests.rs index 4e0345331..cc5527c40 100644 --- a/tests/integration/pm_tests.rs +++ b/tests/integration/pm_tests.rs @@ -48,6 +48,38 @@ fn add_basic_no_deno_json() { })); } +#[test] +fn add_version_contraint() { + let context = pm_context_builder().build(); + let temp_dir = context.temp_dir().path(); + + let output = context.new_command().args("add @denotest/add@1").run(); + output.assert_exit_code(0); + let output = output.combined_output(); + assert_contains!(output, "Add @denotest/add"); + temp_dir.join("deno.json").assert_matches_json(json!({ + "imports": { + "@denotest/add": "jsr:@denotest/add@^1.0.0" + } + })); +} + +#[test] +fn add_tilde() { + let context = pm_context_builder().build(); + let temp_dir = context.temp_dir().path(); + + let output = context.new_command().args("add @denotest/add@~1").run(); + output.assert_exit_code(0); + let output = output.combined_output(); + assert_contains!(output, "Add @denotest/add"); + temp_dir.join("deno.json").assert_matches_json(json!({ + "imports": { + "@denotest/add": "jsr:@denotest/add@~1.0.0" + } + })); +} + #[test] fn add_multiple() { let starting_deno_json = json!({ @@ -90,16 +122,6 @@ fn add_not_supported_npm() { assert_contains!(output, "error: Adding npm: packages is currently not supported. Package: npm:express"); } -#[test] -fn add_not_supported_version_constraint() { - let context = pm_context_builder().build(); - - let output = context.new_command().args("add @denotest/add@1").run(); - output.assert_exit_code(1); - let output = output.combined_output(); - assert_contains!(output, "error: Specifying version constraints is currently not supported. Package: jsr:@denotest/add@1"); -} - fn pm_context_builder() -> TestContextBuilder { TestContextBuilder::new() .use_http_server() -- cgit v1.2.3