summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-08-13 12:30:59 -0400
committerGitHub <noreply@github.com>2019-08-13 12:30:59 -0400
commit7424e9674cb2a966938861f4257a0b2963f5cdca (patch)
treeacbcc1c20a64da41911b0c1700a9bc24370be6c2
parent589b6cf712d90a0ac2c70999dd57f32375f423a0 (diff)
fix: Fix issues with nodejs and golang configuration (#146)
* fix: Give all modules a single name * test: Add missing config tests for nodejs and golang * test: Rename dir to directory
-rw-r--r--src/modules/golang.rs2
-rw-r--r--src/modules/mod.rs10
-rw-r--r--src/modules/nodejs.rs2
-rw-r--r--tests/testsuite/cmd_duration.rs3
-rw-r--r--tests/testsuite/directory.rs28
-rw-r--r--tests/testsuite/golang.rs23
-rw-r--r--tests/testsuite/nodejs.rs23
7 files changed, 68 insertions, 23 deletions
diff --git a/src/modules/golang.rs b/src/modules/golang.rs
index 17af7d5f6..0114c30de 100644
--- a/src/modules/golang.rs
+++ b/src/modules/golang.rs
@@ -30,7 +30,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
const GO_CHAR: &str = "🐹 ";
let module_color = Color::Cyan.bold();
- let mut module = context.new_module("go")?;
+ let mut module = context.new_module("golang")?;
module.set_style(module_color);
let formatted_version = format_go_version(&go_version)?;
diff --git a/src/modules/mod.rs b/src/modules/mod.rs
index 9171f2a3e..35bbe2d31 100644
--- a/src/modules/mod.rs
+++ b/src/modules/mod.rs
@@ -18,12 +18,12 @@ use crate::module::Module;
pub fn handle<'a>(module: &str, context: &'a Context) -> Option<Module<'a>> {
match module {
- "dir" | "directory" => directory::module(context),
- "char" | "character" => character::module(context),
- "node" | "nodejs" => nodejs::module(context),
- "rust" | "rustlang" => rust::module(context),
+ "directory" => directory::module(context),
+ "character" => character::module(context),
+ "nodejs" => nodejs::module(context),
+ "rust" => rust::module(context),
"python" => python::module(context),
- "go" | "golang" => golang::module(context),
+ "golang" => golang::module(context),
"line_break" => line_break::module(context),
"package" => package::module(context),
"git_branch" => git_branch::module(context),
diff --git a/src/modules/nodejs.rs b/src/modules/nodejs.rs
index eddbc5a7e..c7029d88c 100644
--- a/src/modules/nodejs.rs
+++ b/src/modules/nodejs.rs
@@ -26,7 +26,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
const NODE_CHAR: &str = "⬢ ";
let module_color = Color::Green.bold();
- let mut module = context.new_module("node")?;
+ let mut module = context.new_module("nodejs")?;
module.set_style(module_color);
let formatted_version = node_version.trim();
diff --git a/tests/testsuite/cmd_duration.rs b/tests/testsuite/cmd_duration.rs
index a7cf5e957..a82790327 100644
--- a/tests/testsuite/cmd_duration.rs
+++ b/tests/testsuite/cmd_duration.rs
@@ -1,8 +1,5 @@
use ansi_term::Color;
-use std::fs;
use std::io;
-use std::path::Path;
-use tempfile::TempDir;
use crate::common::{self, TestCommand};
diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs
index 1a5e67ddc..a390c0abd 100644
--- a/tests/testsuite/directory.rs
+++ b/tests/testsuite/directory.rs
@@ -10,7 +10,9 @@ use crate::common::{self, TestCommand};
#[test]
fn home_directory() -> io::Result<()> {
- let output = common::render_module("dir").arg("--path=~").output()?;
+ let output = common::render_module("directory")
+ .arg("--path=~")
+ .output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = format!("in {} ", Color::Cyan.bold().paint("~"));
@@ -24,7 +26,7 @@ fn directory_in_home() -> io::Result<()> {
let dir = home_dir().unwrap().join("starship/engine");
fs::create_dir_all(&dir)?;
- let output = common::render_module("dir")
+ let output = common::render_module("directory")
.arg("--path")
.arg(dir)
.output()?;
@@ -41,7 +43,7 @@ fn truncated_directory_in_home() -> io::Result<()> {
let dir = home_dir().unwrap().join("starship/engine/schematics");
fs::create_dir_all(&dir)?;
- let output = common::render_module("dir")
+ let output = common::render_module("directory")
.arg("--path")
.arg(dir)
.output()?;
@@ -57,7 +59,9 @@ fn truncated_directory_in_home() -> io::Result<()> {
#[test]
fn root_directory() -> io::Result<()> {
- let output = common::render_module("dir").arg("--path=/").output()?;
+ let output = common::render_module("directory")
+ .arg("--path=/")
+ .output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = format!("in {} ", Color::Cyan.bold().paint("/"));
@@ -67,7 +71,9 @@ fn root_directory() -> io::Result<()> {
#[test]
fn directory_in_root() -> io::Result<()> {
- let output = common::render_module("dir").arg("--path=/usr").output()?;
+ let output = common::render_module("directory")
+ .arg("--path=/usr")
+ .output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = format!("in {} ", Color::Cyan.bold().paint("/usr"));
@@ -81,7 +87,7 @@ fn truncated_directory_in_root() -> io::Result<()> {
let dir = Path::new("/tmp/starship/thrusters/rocket");
fs::create_dir_all(&dir)?;
- let output = common::render_module("dir")
+ let output = common::render_module("directory")
.arg("--path")
.arg(dir)
.output()?;
@@ -101,7 +107,7 @@ fn truncated_directory_config_large() -> io::Result<()> {
let dir = Path::new("/tmp/starship/thrusters/rocket");
fs::create_dir_all(&dir)?;
- let output = common::render_module("dir")
+ let output = common::render_module("directory")
.use_config(toml::toml! {
[directory]
truncation_length = 100
@@ -125,7 +131,7 @@ fn truncated_directory_config_small() -> io::Result<()> {
let dir = Path::new("/tmp/starship/thrusters/rocket");
fs::create_dir_all(&dir)?;
- let output = common::render_module("dir")
+ let output = common::render_module("directory")
.use_config(toml::toml! {
[directory]
truncation_length = 2
@@ -151,7 +157,7 @@ fn git_repo_root() -> io::Result<()> {
fs::create_dir(&repo_dir)?;
Repository::init(&repo_dir).unwrap();
- let output = common::render_module("dir")
+ let output = common::render_module("directory")
.arg("--path")
.arg(repo_dir)
.output()?;
@@ -171,7 +177,7 @@ fn directory_in_git_repo() -> io::Result<()> {
fs::create_dir_all(&dir)?;
Repository::init(&repo_dir).unwrap();
- let output = common::render_module("dir")
+ let output = common::render_module("directory")
.arg("--path")
.arg(dir)
.output()?;
@@ -191,7 +197,7 @@ fn truncated_directory_in_git_repo() -> io::Result<()> {
fs::create_dir_all(&dir)?;
Repository::init(&repo_dir).unwrap();
- let output = common::render_module("dir")
+ let output = common::render_module("directory")
.arg("--path")
.arg(dir)
.output()?;
diff --git a/tests/testsuite/golang.rs b/tests/testsuite/golang.rs
index 6419eefb7..c63e25c0b 100644
--- a/tests/testsuite/golang.rs
+++ b/tests/testsuite/golang.rs
@@ -2,7 +2,7 @@ use ansi_term::Color;
use std::fs::{self, File};
use std::io;
-use crate::common;
+use crate::common::{self, TestCommand};
#[test]
fn folder_without_go_files() -> io::Result<()> {
@@ -138,3 +138,24 @@ fn folder_with_gopkg_lock() -> io::Result<()> {
assert_eq!(expected, actual);
Ok(())
}
+
+#[test]
+#[ignore]
+fn config_disabled() -> io::Result<()> {
+ let dir = common::new_tempdir()?;
+ File::create(dir.path().join("main.go"))?;
+
+ let output = common::render_module("golang")
+ .use_config(toml::toml! {
+ [golang]
+ disabled = true
+ })
+ .arg("--path")
+ .arg(dir.path())
+ .output()?;
+ let actual = String::from_utf8(output.stdout).unwrap();
+
+ let expected = "";
+ assert_eq!(expected, actual);
+ Ok(())
+}
diff --git a/tests/testsuite/nodejs.rs b/tests/testsuite/nodejs.rs
index 33b0df2af..bea6248a1 100644
--- a/tests/testsuite/nodejs.rs
+++ b/tests/testsuite/nodejs.rs
@@ -2,7 +2,7 @@ use ansi_term::Color;
use std::fs::{self, File};
use std::io;
-use crate::common;
+use crate::common::{self, TestCommand};
#[test]
fn folder_without_node_files() -> io::Result<()> {
@@ -70,3 +70,24 @@ fn folder_with_node_modules() -> io::Result<()> {
assert_eq!(expected, actual);
Ok(())
}
+
+#[test]
+#[ignore]
+fn config_disabled() -> io::Result<()> {
+ let dir = common::new_tempdir()?;
+ File::create(dir.path().join("package.json"))?;
+
+ let output = common::render_module("nodejs")
+ .use_config(toml::toml! {
+ [nodejs]
+ disabled = true
+ })
+ .arg("--path")
+ .arg(dir.path())
+ .output()?;
+ let actual = String::from_utf8(output.stdout).unwrap();
+
+ let expected = "";
+ assert_eq!(expected, actual);
+ Ok(())
+}