File: git-authors.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 (57 lines) | stat: -rw-r--r-- 1,215 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
# shellcheck shell=bash

source "$BATS_TEST_DIRNAME/test_util.sh"


setup_file() {
	test_util.setup_file
}

setup() {
	test_util.cd_test

	test_util.git_init

	git config user.name 'test'
	git config user.email 'test@example.com'
	printf '%s\n' 'A' > tmpfile
	git add .
	git commit -m 'test: add data A'

	git config user.name 'testagain'
	git config user.email 'testagain@example.com'
	printf '%s\n' 'B' > tmpfile
	git add .
	git commit -m 'test: add data B'

	# git config unset user.name
	# git config unset user.email
}

@test "output authors has email without any parameter" {
	run git authors
	assert_success

	local content=$(<AUTHORS)
	assert_equal "$content" $'test <test@example.com>\ntestagain <testagain@example.com>'
}

@test "list authors has email defaultly" {
	run git authors --list
	assert_output $'test <test@example.com>\ntestagain <testagain@example.com>'
	assert_success

	run git authors -l
	assert_output $'test <test@example.com>\ntestagain <testagain@example.com>'
	assert_success
}

@test "list authors has no email" {
	run git authors --list --no-email
	assert_output $'test\ntestagain'
	assert_success

	run git authors -l --no-email
	assert_output $'test\ntestagain'
	assert_success
}