diff options
Diffstat (limited to 'tests/integration')
| -rw-r--r-- | tests/integration/check_tests.rs | 15 | ||||
| -rw-r--r-- | tests/integration/jsr_tests.rs | 26 | ||||
| -rw-r--r-- | tests/integration/npm_tests.rs | 11 | ||||
| -rw-r--r-- | tests/integration/run_tests.rs | 54 |
4 files changed, 40 insertions, 66 deletions
diff --git a/tests/integration/check_tests.rs b/tests/integration/check_tests.rs index f0e3dfb5a..ce464135b 100644 --- a/tests/integration/check_tests.rs +++ b/tests/integration/check_tests.rs @@ -1,6 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use deno_lockfile::NewLockfileOptions; +use deno_semver::jsr::JsrDepPackageReq; use test_util as util; use test_util::itest; use util::env_vars_for_npm_tests; @@ -372,8 +373,11 @@ fn npm_module_check_then_error() { // make the specifier resolve to version 1 lockfile.content.packages.specifiers.insert( - "npm:@denotest/breaking-change-between-versions".to_string(), - "npm:@denotest/breaking-change-between-versions@1.0.0".to_string(), + JsrDepPackageReq::from_str( + "npm:@denotest/breaking-change-between-versions", + ) + .unwrap(), + "1.0.0".to_string(), ); lockfile_path.write(lockfile.as_json_string()); temp_dir.write( @@ -387,8 +391,11 @@ fn npm_module_check_then_error() { // now update the lockfile to use version 2 instead, which should cause a // type checking error because the oldName no longer exists lockfile.content.packages.specifiers.insert( - "npm:@denotest/breaking-change-between-versions".to_string(), - "npm:@denotest/breaking-change-between-versions@2.0.0".to_string(), + JsrDepPackageReq::from_str( + "npm:@denotest/breaking-change-between-versions", + ) + .unwrap(), + "2.0.0".to_string(), ); lockfile_path.write(lockfile.as_json_string()); diff --git a/tests/integration/jsr_tests.rs b/tests/integration/jsr_tests.rs index f31b53f27..af5b24fe4 100644 --- a/tests/integration/jsr_tests.rs +++ b/tests/integration/jsr_tests.rs @@ -6,6 +6,8 @@ use deno_core::serde_json::json; use deno_core::serde_json::Value; use deno_lockfile::Lockfile; use deno_lockfile::NewLockfileOptions; +use deno_semver::jsr::JsrDepPackageReq; +use deno_semver::package::PackageNv; use test_util as util; use url::Url; use util::assert_contains; @@ -154,8 +156,10 @@ console.log(version);"#, .content .packages .specifiers - .get_mut("jsr:@denotest/no-module-graph@0.1") - .unwrap() = "jsr:@denotest/no-module-graph@0.1.0".to_string(); + .get_mut( + &JsrDepPackageReq::from_str("jsr:@denotest/no-module-graph@0.1").unwrap(), + ) + .unwrap() = "0.1.0".to_string(); lockfile_path.write(lockfile.as_json_string()); test_context @@ -276,9 +280,9 @@ console.log(version);"#, overwrite: false, }) .unwrap(); - let pkg_name = "@denotest/no-module-graph@0.1.1"; - let original_integrity = get_lockfile_pkg_integrity(&lockfile, pkg_name); - set_lockfile_pkg_integrity(&mut lockfile, pkg_name, "bad_integrity"); + let pkg_nv = "@denotest/no-module-graph@0.1.1"; + let original_integrity = get_lockfile_pkg_integrity(&lockfile, pkg_nv); + set_lockfile_pkg_integrity(&mut lockfile, pkg_nv, "bad_integrity"); lockfile_path.write(lockfile.as_json_string()); let actual_integrity = @@ -317,7 +321,7 @@ Investigate the lockfile; delete it to regenerate the lockfile or --reload to re .assert_exit_code(10); // now update to the correct integrity - set_lockfile_pkg_integrity(&mut lockfile, pkg_name, &original_integrity); + set_lockfile_pkg_integrity(&mut lockfile, pkg_nv, &original_integrity); lockfile_path.write(lockfile.as_json_string()); // should pass now @@ -329,7 +333,7 @@ Investigate the lockfile; delete it to regenerate the lockfile or --reload to re .assert_exit_code(0); // now update to a bad integrity again - set_lockfile_pkg_integrity(&mut lockfile, pkg_name, "bad_integrity"); + set_lockfile_pkg_integrity(&mut lockfile, pkg_nv, "bad_integrity"); lockfile_path.write(lockfile.as_json_string()); // shouldn't matter because we have a vendor folder @@ -400,12 +404,12 @@ If you modified your global cache, run again with the --reload flag to restore i .assert_exit_code(10); } -fn get_lockfile_pkg_integrity(lockfile: &Lockfile, pkg_name: &str) -> String { +fn get_lockfile_pkg_integrity(lockfile: &Lockfile, pkg_nv: &str) -> String { lockfile .content .packages .jsr - .get(pkg_name) + .get(&PackageNv::from_str(pkg_nv).unwrap()) .unwrap() .integrity .clone() @@ -413,14 +417,14 @@ fn get_lockfile_pkg_integrity(lockfile: &Lockfile, pkg_name: &str) -> String { fn set_lockfile_pkg_integrity( lockfile: &mut Lockfile, - pkg_name: &str, + pkg_nv: &str, integrity: &str, ) { lockfile .content .packages .jsr - .get_mut(pkg_name) + .get_mut(&PackageNv::from_str(pkg_nv).unwrap()) .unwrap() .integrity = integrity.to_string(); } diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs index 2babcb21e..f4bf3d6e9 100644 --- a/tests/integration/npm_tests.rs +++ b/tests/integration/npm_tests.rs @@ -272,13 +272,6 @@ itest!(nonexistent_file_node_modules_dir { exit_code: 1, }); -itest!(invalid_package_name { - args: "run -A --quiet npm/invalid_package_name/main.js", - output: "npm/invalid_package_name/main.out", - envs: env_vars_for_npm_tests(), - exit_code: 1, -}); - itest!(require_json { args: "run -A --quiet npm/require_json/main.js", output: "npm/require_json/main.out", @@ -1218,7 +1211,7 @@ fn lock_file_lock_write() { let lock_file_content = r#"{ "version": "4", "specifiers": { - "npm:cowsay@1.5.0": "npm:cowsay@1.5.0" + "npm:cowsay@1.5.0": "1.5.0" }, "npm": { "ansi-regex@3.0.1": { @@ -1428,7 +1421,7 @@ fn auto_discover_lock_file() { let lock_file_content = r#"{ "version": "4", "specifiers": { - "npm:@denotest/bin": "npm:@denotest/bin@1.0.0" + "npm:@denotest/bin": "1.0.0" }, "npm": { "@denotest/bin@1.0.0": { diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index ad20b77e1..64e9d1c22 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -923,7 +923,7 @@ fn lock_redirects() { r#"{ "version": "4", "specifiers": { - "npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0" + "npm:@denotest/esm-basic@*": "1.0.0" }, "npm": { "@denotest/esm-basic@1.0.0": { @@ -974,8 +974,8 @@ fn lock_deno_json_package_json_deps() { lockfile.assert_matches_json(json!({ "version": "4", "specifiers": { - "jsr:@denotest/module-graph@1.4": "jsr:@denotest/module-graph@1.4.0", - "npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0" + "jsr:@denotest/module-graph@1.4": "1.4.0", + "npm:@denotest/esm-basic@*": "1.0.0" }, "jsr": { "@denotest/module-graph@1.4.0": { @@ -990,7 +990,7 @@ fn lock_deno_json_package_json_deps() { "workspace": { "dependencies": [ "jsr:@denotest/module-graph@1.4", - "npm:@denotest/esm-basic" + "npm:@denotest/esm-basic@*" ] } })); @@ -1022,8 +1022,8 @@ fn lock_deno_json_package_json_deps() { lockfile.assert_matches_json(json!({ "version": "4", "specifiers": { - "jsr:@denotest/module-graph@1.4": "jsr:@denotest/module-graph@1.4.0", - "npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0" + "jsr:@denotest/module-graph@1.4": "1.4.0", + "npm:@denotest/esm-basic@*": "1.0.0" }, "jsr": { "@denotest/module-graph@1.4.0": { @@ -1041,7 +1041,7 @@ fn lock_deno_json_package_json_deps() { ], "packageJson": { "dependencies": [ - "npm:@denotest/esm-basic" + "npm:@denotest/esm-basic@*" ] } } @@ -1059,7 +1059,7 @@ fn lock_deno_json_package_json_deps() { lockfile.assert_matches_json(json!({ "version": "4", "specifiers": { - "jsr:@denotest/module-graph@1.4": "jsr:@denotest/module-graph@1.4.0", + "jsr:@denotest/module-graph@1.4": "1.4.0", }, "jsr": { "@denotest/module-graph@1.4.0": { @@ -1143,8 +1143,8 @@ fn lock_deno_json_package_json_deps_workspace() { lockfile.assert_matches_json(json!({ "version": "4", "specifiers": { - "npm:@denotest/cjs-default-export@1": "npm:@denotest/cjs-default-export@1.0.0", - "npm:@denotest/esm-basic@1": "npm:@denotest/esm-basic@1.0.0" + "npm:@denotest/cjs-default-export@1": "1.0.0", + "npm:@denotest/esm-basic@1": "1.0.0" }, "npm": { "@denotest/cjs-default-export@1.0.0": { @@ -1186,8 +1186,8 @@ fn lock_deno_json_package_json_deps_workspace() { let expected_lockfile = json!({ "version": "4", "specifiers": { - "npm:@denotest/cjs-default-export@1": "npm:@denotest/cjs-default-export@1.0.0", - "npm:@denotest/esm-basic@1": "npm:@denotest/esm-basic@1.0.0" + "npm:@denotest/cjs-default-export@1": "1.0.0", + "npm:@denotest/esm-basic@1": "1.0.0" }, "npm": { "@denotest/cjs-default-export@1.0.0": { @@ -3463,36 +3463,6 @@ fn package_json_with_deno_json() { } #[test] -fn package_json_error_dep_value_test() { - let context = TestContextBuilder::for_npm() - .use_copy_temp_dir("package_json/invalid_value") - .cwd("package_json/invalid_value") - .build(); - - // should run fine when not referencing a failing dep entry - context - .new_command() - .args("run ok.ts") - .run() - .assert_matches_file("package_json/invalid_value/ok.ts.out"); - - // should fail when referencing a failing dep entry - context - .new_command() - .args("run error.ts") - .run() - .assert_exit_code(1) - .assert_matches_file("package_json/invalid_value/error.ts.out"); - - // should output a warning about the failing dep entry - context - .new_command() - .args("task test") - .run() - .assert_matches_file("package_json/invalid_value/task.out"); -} - -#[test] fn package_json_no_node_modules_dir_created() { // it should not create a node_modules directory let context = TestContextBuilder::new() |
