split out test_helper file.

This commit is contained in:
Paul Irish 2018-02-05 13:02:12 -08:00
parent 7449bfa7e1
commit f80f7ba2d6
2 changed files with 41 additions and 39 deletions

View file

@ -1,14 +1,6 @@
#!/usr/bin/env bats
load "test_helper/bats-support/load"
load "test_helper/bats-assert/load"
foldername="sandboxrepo"
setup() {
create_git_sandbox
export BROWSER=echo
}
load "test_helper/index"
##
## Test environment
@ -388,33 +380,3 @@ setup() {
run ../git-open "--issue"
assert_output "http://tfs.example.com:8080/Project/Folder/_workitems?id=36"
}
teardown() {
cd ..
rm -rf "$foldername"
}
# helper to create a test git sandbox that won't dirty the real repo
function create_git_sandbox() {
rm -rf "$foldername"
mkdir "$foldername"
cd "$foldername"
# safety check. Don't muck with the git repo if we're not inside the sandbox.
assert_equal $(basename $PWD) "$foldername"
git init -q
assert [ -e "../$foldername/.git" ]
git config user.email "test@runner.com" && git config user.name "Test Runner"
# newer git auto-creates the origin remote
if ! git remote add origin "github.com:paulirish/git-open.git"; then
git remote set-url origin "github.com:paulirish/git-open.git"
fi
git checkout -B "master"
echo "ok" > readme.txt
git add readme.txt
git commit -m "add file" -q
}

View file

@ -0,0 +1,40 @@
#!/usr/bin/env bats
load "test_helper/bats-support/load"
load "test_helper/bats-assert/load"
foldername="sandboxrepo"
setup() {
create_git_sandbox
export BROWSER=echo
}
teardown() {
cd ..
rm -rf "$foldername"
}
# helper to create a test git sandbox that won't dirty the real repo
function create_git_sandbox() {
rm -rf "$foldername"
mkdir "$foldername"
cd "$foldername"
# safety check. Don't muck with the git repo if we're not inside the sandbox.
assert_equal $(basename $PWD) "$foldername"
git init -q
assert [ -e "../$foldername/.git" ]
git config user.email "test@runner.com" && git config user.name "Test Runner"
# newer git auto-creates the origin remote
if ! git remote add origin "github.com:paulirish/git-open.git"; then
git remote set-url origin "github.com:paulirish/git-open.git"
fi
git checkout -B "master"
echo "ok" > readme.txt
git add readme.txt
git commit -m "add file" -q
}