mirror of
https://github.com/paulirish/git-open.git
synced 2026-09-10 07:26:15 -04:00
split out test_helper file.
This commit is contained in:
parent
7449bfa7e1
commit
f80f7ba2d6
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
40
test/test_helper/index.bash
Normal file
40
test/test_helper/index.bash
Normal 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
|
||||
}
|
||||
Loading…
Reference in a new issue