From d91b6b7137fbd53486f2225e602c5e0e49a4afe9 Mon Sep 17 00:00:00 2001 From: Thomas O'Donnell Date: Wed, 15 Apr 2020 09:55:32 +0200 Subject: [PATCH] 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. --- tests/testsuite/git_branch.rs | 16 ++++++++++++++++ tests/testsuite/git_commit.rs | 15 +++++++++++++++ tests/testsuite/git_state.rs | 15 +++++++++++++++ tests/testsuite/git_status.rs | 16 ++++++++++++++++ tests/testsuite/hg_branch.rs | 15 +++++++++++++++ tests/testsuite/python.rs | 15 +++++++++++++++ tests/testsuite/singularity.rs | 9 +++++++++ 7 files changed, 101 insertions(+) diff --git a/tests/testsuite/git_branch.rs b/tests/testsuite/git_branch.rs index 7fa5aaae..c8504a4d 100644 --- a/tests/testsuite/git_branch.rs +++ b/tests/testsuite/git_branch.rs @@ -2,9 +2,25 @@ use ansi_term::Color; use remove_dir_all::remove_dir_all; use std::io; use std::process::Command; +use tempfile; 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] fn test_changed_truncation_symbol() -> io::Result<()> { test_truncate_length_with_config( diff --git a/tests/testsuite/git_commit.rs b/tests/testsuite/git_commit.rs index d7ae8e77..cac14807 100644 --- a/tests/testsuite/git_commit.rs +++ b/tests/testsuite/git_commit.rs @@ -5,6 +5,21 @@ use std::{io, str}; 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] fn test_render_commit_hash() -> io::Result<()> { let repo_dir = common::create_fixture_repo()?; diff --git a/tests/testsuite/git_state.rs b/tests/testsuite/git_state.rs index e7da3939..13a0eaed 100644 --- a/tests/testsuite/git_state.rs +++ b/tests/testsuite/git_state.rs @@ -5,6 +5,21 @@ use std::io::{self, Error, ErrorKind, Write}; use std::process::{Command, Stdio}; 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] #[ignore] fn shows_rebasing() -> io::Result<()> { diff --git a/tests/testsuite/git_status.rs b/tests/testsuite/git_status.rs index 58bba46e..eceadb3b 100644 --- a/tests/testsuite/git_status.rs +++ b/tests/testsuite/git_status.rs @@ -4,6 +4,7 @@ use std::fs::{self, File}; use std::io; use std::path::PathBuf; use std::process::Command; +use tempfile; use crate::common::{self, TestCommand}; @@ -19,6 +20,21 @@ fn barrier() { 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] #[ignore] fn shows_behind() -> io::Result<()> { diff --git a/tests/testsuite/hg_branch.rs b/tests/testsuite/hg_branch.rs index df600b69..41bec34e 100644 --- a/tests/testsuite/hg_branch.rs +++ b/tests/testsuite/hg_branch.rs @@ -16,6 +16,21 @@ enum Expect<'a> { 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] #[ignore] fn test_hg_get_branch_fails() -> io::Result<()> { diff --git a/tests/testsuite/python.rs b/tests/testsuite/python.rs index a432f5fe..ffc66612 100644 --- a/tests/testsuite/python.rs +++ b/tests/testsuite/python.rs @@ -6,6 +6,21 @@ use tempfile; 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] #[ignore] fn folder_with_python_version() -> io::Result<()> { diff --git a/tests/testsuite/singularity.rs b/tests/testsuite/singularity.rs index 26067baa..84ae45e6 100644 --- a/tests/testsuite/singularity.rs +++ b/tests/testsuite/singularity.rs @@ -3,6 +3,15 @@ use std::io; 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] fn env_set() -> io::Result<()> { let output = common::render_module("singularity")