1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-28 15:56:28 +00:00

test: Add null tests to modules that don't have them (#1104)

Have added some null tests to modules that don't already have them.
This commit is contained in:
Thomas O'Donnell 2020-04-15 09:55:32 +02:00 committed by GitHub
parent d13d508ca2
commit d91b6b7137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 101 additions and 0 deletions

View File

@ -2,9 +2,25 @@ use ansi_term::Color;
use remove_dir_all::remove_dir_all; use remove_dir_all::remove_dir_all;
use std::io; use std::io;
use std::process::Command; use std::process::Command;
use tempfile;
use crate::common::{self, TestCommand}; use crate::common::{self, TestCommand};
#[test]
fn show_nothing_on_empty_dir() -> io::Result<()> {
let repo_dir = tempfile::tempdir()?;
let output = common::render_module("git_branch")
.arg("--path")
.arg(repo_dir.path())
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = "";
assert_eq!(expected, actual);
repo_dir.close()
}
#[test] #[test]
fn test_changed_truncation_symbol() -> io::Result<()> { fn test_changed_truncation_symbol() -> io::Result<()> {
test_truncate_length_with_config( test_truncate_length_with_config(

View File

@ -5,6 +5,21 @@ use std::{io, str};
use crate::common::{self, TestCommand}; use crate::common::{self, TestCommand};
#[test]
fn show_nothing_on_empty_dir() -> io::Result<()> {
let repo_dir = tempfile::tempdir()?;
let output = common::render_module("git_commit")
.arg("--path")
.arg(repo_dir.path())
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = "";
assert_eq!(expected, actual);
repo_dir.close()
}
#[test] #[test]
fn test_render_commit_hash() -> io::Result<()> { fn test_render_commit_hash() -> io::Result<()> {
let repo_dir = common::create_fixture_repo()?; let repo_dir = common::create_fixture_repo()?;

View File

@ -5,6 +5,21 @@ use std::io::{self, Error, ErrorKind, Write};
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use tempfile; use tempfile;
#[test]
fn show_nothing_on_empty_dir() -> io::Result<()> {
let repo_dir = tempfile::tempdir()?;
let output = common::render_module("git_state")
.arg("--path")
.arg(repo_dir.path())
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = "";
assert_eq!(expected, actual);
repo_dir.close()
}
#[test] #[test]
#[ignore] #[ignore]
fn shows_rebasing() -> io::Result<()> { fn shows_rebasing() -> io::Result<()> {

View File

@ -4,6 +4,7 @@ use std::fs::{self, File};
use std::io; use std::io;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;
use tempfile;
use crate::common::{self, TestCommand}; use crate::common::{self, TestCommand};
@ -19,6 +20,21 @@ fn barrier() {
std::thread::sleep(std::time::Duration::from_millis(500)); std::thread::sleep(std::time::Duration::from_millis(500));
} }
#[test]
fn show_nothing_on_empty_dir() -> io::Result<()> {
let repo_dir = tempfile::tempdir()?;
let output = common::render_module("git_status")
.arg("--path")
.arg(repo_dir.path())
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = "";
assert_eq!(expected, actual);
repo_dir.close()
}
#[test] #[test]
#[ignore] #[ignore]
fn shows_behind() -> io::Result<()> { fn shows_behind() -> io::Result<()> {

View File

@ -16,6 +16,21 @@ enum Expect<'a> {
TruncationSymbol(&'a str), TruncationSymbol(&'a str),
} }
#[test]
fn show_nothing_on_empty_dir() -> io::Result<()> {
let repo_dir = tempfile::tempdir()?;
let output = common::render_module("hg_branch")
.arg("--path")
.arg(repo_dir.path())
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = "";
assert_eq!(expected, actual);
repo_dir.close()
}
#[test] #[test]
#[ignore] #[ignore]
fn test_hg_get_branch_fails() -> io::Result<()> { fn test_hg_get_branch_fails() -> io::Result<()> {

View File

@ -6,6 +6,21 @@ use tempfile;
use crate::common::{self, TestCommand}; use crate::common::{self, TestCommand};
#[test]
fn show_nothing_on_empty_dir() -> io::Result<()> {
let dir = tempfile::tempdir()?;
let output = common::render_module("python")
.arg("--path")
.arg(dir.path())
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = "";
assert_eq!(expected, actual);
dir.close()
}
#[test] #[test]
#[ignore] #[ignore]
fn folder_with_python_version() -> io::Result<()> { fn folder_with_python_version() -> io::Result<()> {

View File

@ -3,6 +3,15 @@ use std::io;
use crate::common; use crate::common;
#[test]
fn no_env_set() -> io::Result<()> {
let output = common::render_module("singularity").output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = "";
assert_eq!(expected, actual);
Ok(())
}
#[test] #[test]
fn env_set() -> io::Result<()> { fn env_set() -> io::Result<()> {
let output = common::render_module("singularity") let output = common::render_module("singularity")