From 07d75b2e1edfc9269fbe4e5d80c07d06aa2bc006 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Fri, 27 Oct 2017 14:18:02 -0700 Subject: [PATCH] add test for bitbucket server (#83) * add test for bitbucket server * add branch test for bb server. * updated assertions from discussion. * remove 'git/' from test cases --- test/git-open.bats | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/git-open.bats b/test/git-open.bats index 7ff40d8..48da34d 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -194,6 +194,45 @@ setup() { } +@test "bitbucket: Bitbucket Server" { + # https://github.com/paulirish/git-open/issues/77#issuecomment-309044010 + git remote set-url origin "https://user@mybb.domain.com/scm/ppp/rrr.git" + run ../git-open + + # any of the following are acceptable + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr" || + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse/?at=master" || + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse/?at=refs%2Fheads%2Fmaster" +} + +@test "bitbucket: Bitbucket Server branch" { + # https://github.com/paulirish/git-open/issues/80 + git remote set-url origin "https://user@mybb.domain.com/scm/ppp/rrr.git" + git checkout -B "develop" + run ../git-open + + # The following query args work with BB Server: + # at=refs%2Fheads%2Fdevelop, at=develop, at=refs/heads/develop + # However /src/develop does not (unlike bitbucket.org) + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse?at=develop" || + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse?at=refs%2Fheads%2Fdevelop" || + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse?at=refs/heads/develop" + + refute_output --partial "/src/develop" +} + + +@test "bitbucket: Bitbucket Server private user repos" { + # https://github.com/paulirish/git-open/pull/83#issuecomment-309968538 + git remote set-url origin "https://mybb.domain.com/scm/~first.last/rrr.git" + git checkout -B "develop" + run ../git-open + assert_output "https://mybb.domain.com/projects/~first.last/repos/rrr/browse?at=develop" || + assert_output "https://mybb.domain.com/projects/~first.last/repos/rrr/browse?at=refs%2Fheads%2Fdevelop" || + assert_output "https://mybb.domain.com/projects/~first.last/repos/rrr/browse?at=refs/heads/develop" + +} + ## ## GitLab ##