From 2ef17f07d8d243595aa66b90609746e4f60dadae Mon Sep 17 00:00:00 2001 From: Yohei TSUJI Date: Thu, 9 Aug 2018 10:10:21 +0900 Subject: [PATCH] Added test cases for AWS Code Commit. --- git-open | 5 +++++ test/git-open.bats | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/git-open b/git-open index 65b6af4..67103f3 100755 --- a/git-open +++ b/git-open @@ -198,6 +198,11 @@ elif [[ "${#pathargs[@]}" -ge '2' && ${pathargs[${#pathargs[@]} - 2]} == '_git' fi elif [[ "$domain" =~ amazonaws\.com$ ]]; then # AWS Code Commit + if (( is_issue )); then + echo "Issue feature does not supported on AWS Code Commit." 1>&2 + exit 1 + fi + # Take region name from domain. region=${domain#*.} region=${region%%.*} diff --git a/test/git-open.bats b/test/git-open.bats index 50808ac..c070606 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -503,6 +503,39 @@ setup() { assert_output "https://gitopen.visualstudio.com/Project/_workitems?id=36" } +## +## AWS Code Commit +## + +@test "aws: https url" { + git remote set-url origin "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/repo" + git checkout -B "master" + run ../git-open + assert_output "https://us-east-1.console.aws.amazon.com/codecommit/home?region=us-east-1#/repository/repo/browse/" +} + +@test "aws: ssh url" { + git remote set-url origin "ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/repo" + git checkout -B "master" + run ../git-open + assert_output "https://us-east-1.console.aws.amazon.com/codecommit/home?region=us-east-1#/repository/repo/browse/" +} + +@test "aws: branch " { + git remote set-url origin "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/repo" + git checkout -B "mybranch" + run ../git-open + assert_output "https://us-east-1.console.aws.amazon.com/codecommit/home?region=us-east-1#/repository/repo/browse/mybranch/--/" +} + +@test "aws: issue" { + git remote set-url origin "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/repo" + git checkout -B "issues/#12" + run ../git-open "--issue" + [ "$status" -eq 1 ] + assert_output "Issue feature does not supported on AWS Code Commit." +} + teardown() { cd ..