diff --git a/package.json b/package.json index 96ffdcb..ee86b60 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,8 @@ "lint:editorconfig": "eclint check git-open* readme* .travis.yml", "lint:package": "pjv --recommendations --warnings", "lint:readme": "node ./node_modules/markdownlint/lib/markdownlint.js --config markdownlint.json README.md", - "test": "npm run lint:package && npm run lint:readme && npm run lint:editorconfig", + "test": "npm run unit && npm run lint:package && npm run lint:readme && npm run lint:editorconfig", + "unit": "bats test/", "watch": "find . -maxdepth 2 -iname '*bats' -o -iname 'git-open' | entr bats test/" }, "dependencies": {}, diff --git a/test/git-open.bats b/test/git-open.bats index 1c177fa..2b48982 100644 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -192,7 +192,7 @@ setup() { assert_output "https://gitlab.example.com/user/repo" } -@test "gitlab: ssh:// origin style" { +@test "gitlab: ssh://git@ origin" { # https://github.com/paulirish/git-open/pull/51 git remote set-url origin "ssh://git@gitlab.domain.com/user/repo" git config "gitopen.gitlab.domain" "gitlab.domain.com" @@ -201,6 +201,24 @@ setup() { refute_output --partial "//" } +@test "gitlab: ssh://git@host:port origin" { + # https://github.com/paulirish/git-open/pull/76 + # this first set mostly matches the "gitlab: ssh://git@ origin" test + git remote set-url origin "ssh://git@repo.intranet/XXX/YYY.git" + git config "gitopen.gitlab.domain" "repo.intranet" + run ../git-open + assert_output "https://repo.intranet/XXX/YYY/" + refute_output --partial "ssh://" + refute_output --partial "//XXX" + + git remote set-url origin "ssh://git@repo.intranet:7000/XXX/YYY.git" + git config "gitopen.gitlab.domain" "repo.intranet" + git config "gitopen.gitlab.ssh.port" "7000" + run ../git-open + assert_output "https://repo.intranet/XXX/YYY/" + refute_output --partial "ssh://" + refute_output --partial "//XXX" +} # Tests not yet written: # * gitopen.gitlab.port