-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
500 additions
and
689 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use rstest::rstest; | ||
use rstest_reuse::{self, *}; | ||
use speculoos::assert_that; | ||
|
||
extern crate speculoos; | ||
use crate::speculoos::prelude::ContainingIntoIterAssertions; | ||
|
||
mod testenv; | ||
pub use testenv::*; | ||
|
||
#[apply(shell_to_use)] | ||
fn test_checkout_branches_alias(shell: &str) { | ||
let lines = util::run_command(shell, "Invoke-TabComplete 'myLongGitCheckoutAlias '"); | ||
assert_that!(lines).contains("testbranch".to_string()); | ||
assert_that!(lines).contains("testbranch23".to_string()); | ||
} | ||
|
||
#[apply(shell_to_use)] | ||
fn test_checkout_completions_registered(shell: &str) { | ||
let lines = util::run_command( | ||
shell, | ||
"Get-ArgumentCompleter -Native | ForEach-Object { \"$($_.CommandName)\" }", | ||
); | ||
assert_that!(lines).contains("myLongGitCheckoutAlias".to_string()); | ||
assert_that!(lines).contains("git".to_string()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
use std::io::BufRead; | ||
|
||
use itertools::Itertools; | ||
use rstest::rstest; | ||
use rstest_reuse::{self, *}; | ||
use speculoos::assert_that; | ||
|
||
extern crate speculoos; | ||
use crate::speculoos::prelude::ContainingIntoIterAssertions; | ||
|
||
mod testenv; | ||
pub use testenv::*; | ||
|
||
#[apply(shell_to_use)] | ||
fn test_checkout_branches(shell: &str) { | ||
let lines = util::run_command(shell, "Invoke-TabComplete 'git checkout '"); | ||
assert_that!(lines).contains("testbranch".to_string()); | ||
assert_that!(lines).contains("testbranch23".to_string()); | ||
} | ||
|
||
#[apply(shell_to_use)] | ||
fn test_checkout_branches2(shell: &str) { | ||
let lines = util::run_command(shell, "Invoke-TabComplete 'git checkout testbranch2'"); | ||
assert_that!(lines).contains("testbranch23".to_string()); | ||
} | ||
|
||
#[apply(shell_to_use)] | ||
fn test_merge(shell: &str) { | ||
let lines = util::run_command(shell, "Invoke-TabComplete 'git merge '"); | ||
assert_that!(lines).contains("testbranch".to_string()); | ||
assert_that!(lines).contains("testbranch23".to_string()); | ||
} | ||
|
||
#[apply(shell_to_use)] | ||
fn test_fetch_first_arg(shell: &str) { | ||
let lines = util::run_command(shell, "Invoke-TabComplete 'git fetch '"); | ||
assert_that!(lines).contains("origin".to_string()); | ||
} | ||
|
||
#[apply(shell_to_use)] | ||
fn test_fetch_second_arg(shell: &str) { | ||
let lines = util::run_command(shell, "Invoke-TabComplete 'git fetch origin '"); | ||
assert_that!(lines).contains("testbranch".to_string()); | ||
assert_that!(lines).contains("testbranch23".to_string()); | ||
} | ||
|
||
#[apply(shell_to_use)] | ||
fn test_rebase_first_arg(shell: &str) { | ||
let lines = util::run_command(shell, "Invoke-TabComplete 'git rebase '"); | ||
assert_that!(lines).contains("testbranch".to_string()); | ||
assert_that!(lines).contains("testbranch23".to_string()); | ||
assert_that!(lines).contains("origin".to_string()); | ||
} | ||
|
||
#[apply(shell_to_use)] | ||
fn test_rebase_second_arg(shell: &str) { | ||
let lines = util::run_command(shell, "Invoke-TabComplete 'git rebase origin '"); | ||
assert_that!(lines).contains("testbranch".to_string()); | ||
assert_that!(lines).contains("testbranch23".to_string()); | ||
} | ||
|
||
#[apply(shell_to_use)] | ||
fn test_complete_nongit_command(shell: &str) { | ||
let testenv = TestEnv::new_with_other_nu(shell); | ||
let res = testenv | ||
.run_with_profile("Invoke-TabComplete 'burrito -'") | ||
.unwrap(); | ||
let lines = res.stdout.lines().map(|x| x.unwrap()).collect_vec(); | ||
assert_that!(lines).contains("--hello-there".to_string()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ use std::{ | |
process::{Command, Output}, | ||
}; | ||
use tempfile::TempDir; | ||
pub mod util; | ||
|
||
const PATH: &str = "PATH"; | ||
|
||
|
@@ -142,6 +143,7 @@ fn create_working_dir(profile_prefix_data: Vec<&str>) -> Result<(TempDir, PathBu | |
run_git(&["config", "user.name", "yourname"]); | ||
run_git(&["commit", "-m", "test"]); | ||
run_git(&["checkout", "-b", "testbranch23"]); | ||
run_git(&["remote", "add", "origin", "[email protected]"]); | ||
|
||
profile_path | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use std::io::BufRead; | ||
|
||
use crate::TestEnv; | ||
|
||
pub fn run_command(shell: &str, command: &str) -> Vec<String> { | ||
let testenv = TestEnv::new(shell); | ||
let res = testenv.run_with_profile(command).unwrap(); | ||
res.stdout.lines().map(|x| x.unwrap()).collect() | ||
} |