File: git-browse-ci.bats

package info (click to toggle)
git-extras 7.4.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,120 kB
  • sloc: sh: 4,312; python: 994; makefile: 146
file content (117 lines) | stat: -rw-r--r-- 2,737 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# shellcheck shell=bash

source "$BATS_TEST_DIRNAME/test_util.sh"

setup_file() {
	test_util.setup_file

	PATH="$BATS_TEST_DIRNAME/bin:$PATH"
}

setup() {
	test_util.cd_test

	test_util.git_init
}

get_ci_uri() {
	local mode=$1

	if [ "$mode" = 'github' ]; then
		REPLY="https://github.com/tj/git-extras/actions"
	elif [ "$mode" = 'gitlab' ]; then
		REPLY="https://gitlab.com/tj/git-extras/-/pipelines"
	elif [ "$mode" = 'bitbucket' ]; then
		REPLY="https://bitbucket.org/tj/git-extras/addon/pipelines/home"
	fi
}

@test "works with mac and github" {
	get_ci_uri 'github'
	local expected_url=$REPLY

	git remote add upstream https://github.com/tj/git-extras
	OSTYPE=darwin run git browse-ci upstream
	assert_output "open $expected_url"
	assert_success
}

@test "works with mac and gitlab" {
	get_ci_uri 'gitlab'
	local expected_url=$REPLY

	git remote add upstream https://gitlab.com/tj/git-extras
	OSTYPE=darwin run git browse-ci upstream
	assert_output "open $expected_url"
	assert_success
}

@test "works with mac and bitbucket" {
	get_ci_uri 'bitbucket'
	local expected_url=$REPLY

	git remote add upstream https://bitbucket.org/tj/git-extras
	OSTYPE=darwin run git browse-ci upstream
	assert_output "open $expected_url"
	assert_success
}

@test "works with windows and github" {
	get_ci_uri 'github'
	local expected_url=$REPLY

	git remote add upstream https://github.com/tj/git-extras
	OSTYPE=msys run git browse-ci upstream
	assert_output "start $expected_url"
	assert_success
}

@test "works with windows and gitlab" {
	get_ci_uri 'gitlab'
	local expected_url=$REPLY

	git remote add upstream https://gitlab.com/tj/git-extras
	OSTYPE=msys run git browse-ci upstream
	assert_output "start $expected_url"
	assert_success
}

@test "works with windows and bitbucket" {
	get_ci_uri 'bitbucket'
	local expected_url=$REPLY

	git remote add upstream https://bitbucket.org/tj/git-extras
	OSTYPE=msys run git browse-ci upstream
	assert_output "start $expected_url"
	assert_success
}

@test "works with linux and github" {
	get_ci_uri 'github'
	local expected_url=$REPLY

	git remote add upstream https://github.com/tj/git-extras
	OSTYPE=linux-gnu run git browse-ci upstream
	assert_output "xdg-open $expected_url"
	assert_success
}

@test "works with linux and gitlab" {
	get_ci_uri 'gitlab'
	local expected_url=$REPLY

	git remote add upstream https://gitlab.com/tj/git-extras
	OSTYPE=linux-gnu run git browse-ci upstream
	assert_output "xdg-open $expected_url"
	assert_success
}

@test "works with linux and bitbucket" {
	get_ci_uri 'bitbucket'
	local expected_url=$REPLY

	git remote add upstream https://bitbucket.org/tj/git-extras
	OSTYPE=linux-gnu run git browse-ci upstream
	assert_output "xdg-open $expected_url"
	assert_success
}