summaryrefslogtreecommitdiff
path: root/cli/tests/integration/run_tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/integration/run_tests.rs')
-rw-r--r--cli/tests/integration/run_tests.rs95
1 files changed, 95 insertions, 0 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index 3a385f7cd..22096cb60 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -3,6 +3,7 @@
use deno_core::serde_json::json;
use deno_core::url;
use deno_runtime::deno_fetch::reqwest;
+use pretty_assertions::assert_eq;
use std::io::Read;
use std::io::Write;
use std::process::Command;
@@ -973,6 +974,100 @@ fn lock_no_declaration_files() {
);
}
+#[test]
+fn lock_redirects() {
+ let context = TestContextBuilder::new()
+ .use_temp_cwd()
+ .use_http_server()
+ .add_npm_env_vars()
+ .build();
+ let temp_dir = context.temp_dir();
+ temp_dir.write("deno.json", "{}"); // cause a lockfile to be created
+ temp_dir.write(
+ "main.ts",
+ "import 'http://localhost:4546/run/001_hello.js';",
+ );
+ context
+ .new_command()
+ .args("run main.ts")
+ .run()
+ .skip_output_check();
+ let initial_lockfile_text = r#"{
+ "version": "2",
+ "redirects": {
+ "http://localhost:4546/run/001_hello.js": "http://localhost:4545/run/001_hello.js"
+ },
+ "remote": {
+ "http://localhost:4545/run/001_hello.js": "c479db5ea26965387423ca438bb977d0b4788d5901efcef52f69871e4c1048c5"
+ }
+}
+"#;
+ assert_eq!(temp_dir.read_to_string("deno.lock"), initial_lockfile_text);
+ context
+ .new_command()
+ .args("run main.ts")
+ .run()
+ .assert_matches_text("Hello World\n");
+ assert_eq!(temp_dir.read_to_string("deno.lock"), initial_lockfile_text);
+
+ // now try changing where the redirect occurs in the lockfile
+ temp_dir.write("deno.lock", r#"{
+ "version": "2",
+ "redirects": {
+ "http://localhost:4546/run/001_hello.js": "http://localhost:4545/echo.ts"
+ },
+ "remote": {
+ "http://localhost:4545/run/001_hello.js": "c479db5ea26965387423ca438bb977d0b4788d5901efcef52f69871e4c1048c5"
+ }
+}
+"#);
+
+ // also, add some npm dependency to ensure it doesn't end up in
+ // the redirects as they're currently stored separately
+ temp_dir.write(
+ "main.ts",
+ "import 'http://localhost:4546/run/001_hello.js';\n import 'npm:@denotest/esm-basic';\n",
+ );
+
+ // it should use the echo script instead
+ context
+ .new_command()
+ .args("run main.ts Hi there")
+ .run()
+ .assert_matches_text(
+ concat!(
+ "Download http://localhost:4545/echo.ts\n",
+ "Download http://localhost:4545/npm/registry/@denotest/esm-basic\n",
+ "Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz\n",
+ "Hi, there",
+ ));
+ util::assertions::assert_wildcard_match(
+ &temp_dir.read_to_string("deno.lock"),
+ r#"{
+ "version": "2",
+ "redirects": {
+ "http://localhost:4546/run/001_hello.js": "http://localhost:4545/echo.ts"
+ },
+ "remote": {
+ "http://localhost:4545/echo.ts": "829eb4d67015a695d70b2a33c78b631b29eea1dbac491a6bfcf394af2a2671c2",
+ "http://localhost:4545/run/001_hello.js": "c479db5ea26965387423ca438bb977d0b4788d5901efcef52f69871e4c1048c5"
+ },
+ "npm": {
+ "specifiers": {
+ "@denotest/esm-basic": "@denotest/esm-basic@1.0.0"
+ },
+ "packages": {
+ "@denotest/esm-basic@1.0.0": {
+ "integrity": "sha512-[WILDCARD]",
+ "dependencies": {}
+ }
+ }
+ }
+}
+"#,
+ );
+}
+
itest!(mts_dmts_mjs {
args: "run subdir/import.mts",
output: "run/mts_dmts_mjs.out",