mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-24 21:57:41 +00:00
fix: Fixture repo will now clone and set git config locally (#307)
This commit is contained in:
parent
3435b9cdc2
commit
6658b7f0aa
@ -48,16 +48,9 @@ pub fn new_tempdir() -> io::Result<tempfile::TempDir> {
|
||||
/// Create a repo from the fixture to be used in git module tests
|
||||
pub fn create_fixture_repo() -> io::Result<std::path::PathBuf> {
|
||||
let fixture_repo_dir = new_tempdir()?.path().join("fixture");
|
||||
let repo_dir = new_tempdir()?.path().join("rocket");
|
||||
let fixture = env::current_dir()?.join("tests/fixtures/rocket.bundle");
|
||||
|
||||
Command::new("git")
|
||||
.args(&["config", "--global", "user.email", "starship@example.com"])
|
||||
.output()?;
|
||||
|
||||
Command::new("git")
|
||||
.args(&["config", "--global", "user.name", "starship"])
|
||||
.output()?;
|
||||
|
||||
Command::new("git")
|
||||
.args(&[
|
||||
"clone",
|
||||
@ -68,7 +61,19 @@ pub fn create_fixture_repo() -> io::Result<std::path::PathBuf> {
|
||||
])
|
||||
.output()?;
|
||||
|
||||
Ok(fixture_repo_dir)
|
||||
git2::Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
|
||||
Command::new("git")
|
||||
.args(&["config", "--local", "user.email", "starship@example.com"])
|
||||
.current_dir(repo_dir.as_path())
|
||||
.output()?;
|
||||
|
||||
Command::new("git")
|
||||
.args(&["config", "--local", "user.name", "starship"])
|
||||
.current_dir(repo_dir.as_path())
|
||||
.output()?;
|
||||
|
||||
Ok(repo_dir)
|
||||
}
|
||||
|
||||
/// Extends `std::process::Command` with methods for testing
|
||||
|
@ -106,10 +106,8 @@ fn test_truncate_length_with_config(
|
||||
truncation_symbol: &str,
|
||||
config_options: &str,
|
||||
) -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
Command::new("git")
|
||||
.args(&["checkout", "-b", branch_name])
|
||||
.current_dir(repo_dir.as_path())
|
||||
|
@ -10,10 +10,7 @@ use crate::common::{self, TestCommand};
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_behind() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
Command::new("git")
|
||||
.args(&["reset", "--hard", "HEAD^"])
|
||||
@ -35,10 +32,7 @@ fn shows_behind() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_behind_with_count() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
Command::new("git")
|
||||
.args(&["reset", "--hard", "HEAD^"])
|
||||
@ -67,10 +61,7 @@ fn shows_behind_with_count() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_ahead() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
File::create(repo_dir.join("readme.md"))?;
|
||||
|
||||
@ -94,10 +85,7 @@ fn shows_ahead() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_ahead_with_count() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
File::create(repo_dir.join("readme.md"))?;
|
||||
|
||||
@ -128,10 +116,7 @@ fn shows_ahead_with_count() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_diverged() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
Command::new("git")
|
||||
.args(&["reset", "--hard", "HEAD^"])
|
||||
@ -160,10 +145,7 @@ fn shows_diverged() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_diverged_with_count() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
Command::new("git")
|
||||
.args(&["reset", "--hard", "HEAD^"])
|
||||
@ -199,10 +181,7 @@ fn shows_diverged_with_count() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_conflicted() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
Command::new("git")
|
||||
.args(&["reset", "--hard", "HEAD^"])
|
||||
@ -241,10 +220,7 @@ fn shows_conflicted() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_untracked_file() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
File::create(repo_dir.join("license"))?;
|
||||
|
||||
@ -263,10 +239,7 @@ fn shows_untracked_file() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn doesnt_show_untracked_file_if_disabled() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
File::create(repo_dir.join("license"))?;
|
||||
|
||||
@ -290,10 +263,7 @@ fn doesnt_show_untracked_file_if_disabled() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_stashed() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
File::create(repo_dir.join("readme.md"))?;
|
||||
|
||||
@ -317,10 +287,7 @@ fn shows_stashed() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_modified() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
File::create(repo_dir.join("readme.md"))?;
|
||||
|
||||
@ -339,10 +306,7 @@ fn shows_modified() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_staged_file() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
File::create(repo_dir.join("license"))?;
|
||||
|
||||
@ -366,10 +330,7 @@ fn shows_staged_file() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_renamed_file() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
Command::new("git")
|
||||
.args(&["mv", "readme.md", "readme.md.bak"])
|
||||
@ -396,10 +357,7 @@ fn shows_renamed_file() -> io::Result<()> {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn shows_deleted_file() -> io::Result<()> {
|
||||
let fixture_repo_dir = common::create_fixture_repo()?;
|
||||
let repo_dir = common::new_tempdir()?.path().join("rocket");
|
||||
|
||||
Repository::clone(fixture_repo_dir.to_str().unwrap(), &repo_dir.as_path()).unwrap();
|
||||
let repo_dir = common::create_fixture_repo()?;
|
||||
|
||||
fs::remove_file(repo_dir.join("readme.md"))?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user