From f80f7ba2d6d07bd4e0198b4ab7e13cd1f4493008 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Mon, 5 Feb 2018 13:02:12 -0800 Subject: [PATCH] split out test_helper file. --- test/git-open.bats | 40 +------------------------------------ test/test_helper/index.bash | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 39 deletions(-) create mode 100644 test/test_helper/index.bash diff --git a/test/git-open.bats b/test/git-open.bats index 1577a67..17bdfb1 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -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 -} diff --git a/test/test_helper/index.bash b/test/test_helper/index.bash new file mode 100644 index 0000000..3176bc2 --- /dev/null +++ b/test/test_helper/index.bash @@ -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 +}