From 8709bae844b07a5f567e2a6f0627558ea4baf854 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 15 Jun 2017 15:59:49 -0700 Subject: [PATCH] do testing in sandbox repo. --- test/git-open.bats | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/test/git-open.bats b/test/git-open.bats index 4425f2f..8b4fbeb 100644 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -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 +} \ No newline at end of file