summaryrefslogtreecommitdiffstats
path: root/src/modules/utils
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 /src/modules/utils
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 'src/modules/utils')
-rw-r--r--src/modules/utils/mod.rs3
-rw-r--r--src/modules/utils/test.rs12
2 files changed, 15 insertions, 0 deletions
diff --git a/src/modules/utils/mod.rs b/src/modules/utils/mod.rs
index 6838fb19e..345ce7f40 100644
--- a/src/modules/utils/mod.rs
+++ b/src/modules/utils/mod.rs
@@ -1,2 +1,5 @@
pub mod directory;
pub mod java_version_parser;
+
+#[cfg(test)]
+pub mod test;
diff --git a/src/modules/utils/test.rs b/src/modules/utils/test.rs
new file mode 100644
index 000000000..b3c106b30
--- /dev/null
+++ b/src/modules/utils/test.rs
@@ -0,0 +1,12 @@
+use crate::config::StarshipConfig;
+use crate::context::{Context, Shell};
+use std::path::Path;
+
+/// Render a specific starship module by name
+pub fn render_module(module_name: &str, path: &Path) -> Option<String> {
+ let mut context = Context::new_with_dir(clap::ArgMatches::default(), path);
+ context.config = StarshipConfig { config: None };
+ context.shell = Shell::Unknown;
+
+ crate::print::get_module(module_name, context)
+}