do testing in sandbox repo.

This commit is contained in:
Paul Irish 2017-06-15 15:59:49 -07:00
parent d272912d89
commit 8709bae844

View file

@ -3,22 +3,38 @@
load 'test_helper/bats-support/load'
load 'test_helper/bats-assert/load'
foldername="sandboxrepo"
setup() {
git checkout --force master
create_git_sandbox
}
@test "git-open gh basic" {
run git-open
assert_output 'https://github.com/paulirish/git-open/'
run ../git-open
git remote set-url origin git@github.com:user/repo.git
assert_output 'https://github.com/user/repo/'
}
@test "git-open gh branch" {
git checkout --force -b mybranch
run git-open
assert_output 'https://github.com/paulirish/git-open/tree/mybranch'
run ../git-open
assert_output 'https://github.com/user/repo/tree/mybranch'
}
teardown() {
git branch -D mybranch
git checkout --force master
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"
git init -q
git remote add origin git@github.com:user/repo.git
git checkout -fb master
echo "ok" > readme.txt
git add readme.txt
git commit -m "add file" -q
}