summaryrefslogtreecommitdiff
path: root/cli/tests/integration_tests.rs
diff options
context:
space:
mode:
authorYosi Pramajaya <yosi.pramajaya@gmail.com>2021-02-12 12:54:46 +0700
committerGitHub <noreply@github.com>2021-02-12 14:54:46 +0900
commit146fb360c649f87c6898848bd3ee3610cd7ee8a6 (patch)
tree9ce6d7a9b4b60ff7f0a927b399717c3e8029c217 /cli/tests/integration_tests.rs
parent7f8b44a60d416b0cb2d2b84ef2aac71b4b3e3b31 (diff)
test(cli): improve test of deno cache (#9340)
Diffstat (limited to 'cli/tests/integration_tests.rs')
-rw-r--r--cli/tests/integration_tests.rs38
1 files changed, 33 insertions, 5 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index f4327212f..5fa7c904f 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -5,7 +5,8 @@ use deno_core::serde_json;
use deno_core::url;
use deno_runtime::deno_fetch::reqwest;
use deno_runtime::deno_websocket::tokio_tungstenite;
-use std::io::{BufRead, Write};
+use std::fs;
+use std::io::{BufRead, Read, Write};
use std::process::Command;
use tempfile::TempDir;
use test_util as util;
@@ -336,14 +337,41 @@ mod integration {
.env("DENO_DIR", deno_dir.path())
.current_dir(util::root_path())
.arg("cache")
+ .arg("-L")
+ .arg("debug")
.arg(module_url.to_string())
.output()
.expect("Failed to spawn script");
assert!(output.status.success());
- let out = std::str::from_utf8(&output.stdout).unwrap();
- assert_eq!(out, "");
- // TODO(ry) Is there some way to check that the file was actually cached in
- // DENO_DIR?
+
+ let out = std::str::from_utf8(&output.stderr).unwrap();
+ // Check if file and dependencies are written successfully
+ assert!(out.contains("host.writeFile(\"deno://subdir/print_hello.js\")"));
+ assert!(out.contains("host.writeFile(\"deno://subdir/mod2.js\")"));
+ assert!(out.contains("host.writeFile(\"deno://006_url_imports.js\")"));
+
+ let prg = util::deno_exe_path();
+ let output = Command::new(&prg)
+ .env("DENO_DIR", deno_dir.path())
+ .env("HTTP_PROXY", "http://nil")
+ .env("NO_COLOR", "1")
+ .current_dir(util::root_path())
+ .arg("run")
+ .arg(module_url.to_string())
+ .output()
+ .expect("Failed to spawn script");
+
+ let str_output = std::str::from_utf8(&output.stdout).unwrap();
+
+ let module_output_path =
+ util::root_path().join("cli/tests/006_url_imports.ts.out");
+ let mut module_output = String::new();
+ let mut module_output_file = fs::File::open(module_output_path).unwrap();
+ module_output_file
+ .read_to_string(&mut module_output)
+ .unwrap();
+
+ assert_eq!(module_output, str_output);
}
#[test]