summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.dev>2020-01-26 17:37:18 -0500
committerKevin Song <chipbuster@users.noreply.github.com>2020-01-26 16:37:18 -0600
commit3365beae09af2f12b6323a52f88633ed97b39c51 (patch)
treefb36ec6c06439edd29775fc4a7b1a06041619b69 /tests
parent5342dcc658110f8884a77ef1b3f83e867322ffb5 (diff)
test(nodejs): Port nodejs module tests from E2E to integraton (#867)
Replaces the existing nodejs module end-to-end tests with integration tests that don't require preinstalled environmental dependencies. - Moved the tests to the same file as the module they test - Created a render_module utility function for rendering modules within tests - Removed Node.js installation during CI setup - Add Shell to Context to allow for tests to not run shell-specific code
Diffstat (limited to 'tests')
-rw-r--r--tests/testsuite/main.rs1
-rw-r--r--tests/testsuite/nodejs.rs93
2 files changed, 0 insertions, 94 deletions
diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs
index b7cce9435..f12b60780 100644
--- a/tests/testsuite/main.rs
+++ b/tests/testsuite/main.rs
@@ -19,7 +19,6 @@ mod jobs;
mod line_break;
mod modules;
mod nix_shell;
-mod nodejs;
mod python;
mod ruby;
mod terraform;
diff --git a/tests/testsuite/nodejs.rs b/tests/testsuite/nodejs.rs
deleted file mode 100644
index c0df62a7e..000000000
--- a/tests/testsuite/nodejs.rs
+++ /dev/null
@@ -1,93 +0,0 @@
-use ansi_term::Color;
-use std::fs::{self, File};
-use std::io;
-use tempfile;
-
-use crate::common;
-
-/// Wrapper around common::render_module("nodejs") to work around platform quirks
-fn render_node_module() -> std::process::Command {
- let mut command = common::render_module("nodejs");
-
- // If SYSTEMROOT is not set on Windows node will refuse to print its version
- if cfg!(windows) {
- let system_root = std::env::var("SYSTEMROOT")
- .map(|i| {
- if i.trim().is_empty() {
- "C:\\WINDOWS".into()
- } else {
- i
- }
- })
- .unwrap_or_else(|_| "C:\\WINDOWS".into());
- command.env("SYSTEMROOT", system_root);
- }
- command
-}
-
-#[test]
-fn folder_without_node_files() -> io::Result<()> {
- let dir = tempfile::tempdir()?;
-
- let output = render_node_module()
- .arg("--path")
- .arg(dir.path())
- .output()?;
- let actual = String::from_utf8(output.stdout).unwrap();
-
- let expected = "";
- assert_eq!(expected, actual);
- Ok(())
-}
-
-#[test]
-#[ignore]
-fn folder_with_package_json() -> io::Result<()> {
- let dir = tempfile::tempdir()?;
- File::create(dir.path().join("package.json"))?.sync_all()?;
-
- let output = render_node_module()
- .arg("--path")
- .arg(dir.path())
- .output()?;
- let actual = String::from_utf8(output.stdout).unwrap();
-
- let expected = format!("via {} ", Color::Green.bold().paint("⬢ v12.0.0"));
- assert_eq!(expected, actual);
- Ok(())
-}
-
-#[test]
-#[ignore]
-fn folder_with_js_file() -> io::Result<()> {
- let dir = tempfile::tempdir()?;
- File::create(dir.path().join("index.js"))?.sync_all()?;
-
- let output = render_node_module()
- .arg("--path")
- .arg(dir.path())
- .output()?;
- let actual = String::from_utf8(output.stdout).unwrap();
-
- let expected = format!("via {} ", Color::Green.bold().paint("⬢ v12.0.0"));
- assert_eq!(expected, actual);
- Ok(())
-}
-
-#[test]
-#[ignore]
-fn folder_with_node_modules() -> io::Result<()> {
- let dir = tempfile::tempdir()?;
- let node_modules = dir.path().join("node_modules");
- fs::create_dir_all(&node_modules)?;
-
- let output = render_node_module()
- .arg("--path")
- .arg(dir.path())
- .output()?;
- let actual = String::from_utf8(output.stdout).unwrap();
-
- let expected = format!("via {} ", Color::Green.bold().paint("⬢ v12.0.0"));
- assert_eq!(expected, actual);
- Ok(())
-}