diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2024-03-01 21:34:13 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-01 21:34:13 +0000 |
commit | 15f5f74eb745915e68b3bc16b9ec048b94e26b97 (patch) | |
tree | 2cf1b5a4febadffa77fb0a82fb2e273093034545 /tests/integration/pm_tests.rs | |
parent | 2e4a1fc3e89d00e060ca9d747b6887dae215f0eb (diff) |
feat(unstable/pm): support version contraints in 'deno add' (#22646)
Diffstat (limited to 'tests/integration/pm_tests.rs')
-rw-r--r-- | tests/integration/pm_tests.rs | 42 |
1 files changed, 32 insertions, 10 deletions
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 @@ -49,6 +49,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!({ "name": "@foo/bar", @@ -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() |