|
| 1 | +# shellcheck shell=bash |
| 2 | + |
| 3 | +source "$BATS_TEST_DIRNAME/test_util.sh" |
| 4 | + |
| 5 | +setup_file() { |
| 6 | + test_util.setup_file |
| 7 | +} |
| 8 | + |
| 9 | +setup() { |
| 10 | + test_util.cd_test |
| 11 | + |
| 12 | + git init |
| 13 | + git config --global alias.globalalias status |
| 14 | + git config --global alias.x status |
| 15 | + git config --local alias.localalias status |
| 16 | + git config --local alias.y status |
| 17 | +} |
| 18 | + |
| 19 | +@test "list all works" { |
| 20 | + run git alias |
| 21 | + assert_output - <<-'EOF' |
| 22 | + globalalias = status |
| 23 | + localalias = status |
| 24 | + x = status |
| 25 | + y = status |
| 26 | +EOF |
| 27 | + assert_success |
| 28 | +} |
| 29 | + |
| 30 | +@test "list all globally works" { |
| 31 | + run git alias --global |
| 32 | + assert_output - <<-'EOF' |
| 33 | + globalalias = status |
| 34 | + x = status |
| 35 | +EOF |
| 36 | + assert_success |
| 37 | +} |
| 38 | + |
| 39 | +@test "list all locally works" { |
| 40 | + run git alias --local |
| 41 | + assert_output - <<-'EOF' |
| 42 | + localalias = status |
| 43 | + y = status |
| 44 | +EOF |
| 45 | + assert_success |
| 46 | +} |
| 47 | + |
| 48 | +@test "search globally works" { |
| 49 | + run git alias --global global |
| 50 | + assert_output - <<-'EOF' |
| 51 | + globalalias = status |
| 52 | +EOF |
| 53 | + assert_success |
| 54 | + |
| 55 | + run git alias --global local |
| 56 | + assert_output '' |
| 57 | + assert_failure |
| 58 | +} |
| 59 | + |
| 60 | +@test "search locally works" { |
| 61 | + run git alias --local local |
| 62 | + assert_output - <<-'EOF' |
| 63 | + localalias = status |
| 64 | +EOF |
| 65 | + assert_success |
| 66 | + |
| 67 | + run git alias --local global |
| 68 | + assert_output '' |
| 69 | + assert_failure |
| 70 | +} |
| 71 | + |
| 72 | +@test "get alias globally and defaultly" { |
| 73 | + run git alias globalalias |
| 74 | + assert_output - <<-'EOF' |
| 75 | + globalalias = status |
| 76 | +EOF |
| 77 | + assert_success |
| 78 | +} |
| 79 | + |
| 80 | +@test "set alias globally and defaultly" { |
| 81 | + git alias globalalias diff |
| 82 | + run git alias diff |
| 83 | + assert_output - <<-'EOF' |
| 84 | + globalalias = diff |
| 85 | +EOF |
| 86 | + assert_success |
| 87 | +} |
| 88 | + |
| 89 | +@test "get alias locally" { |
| 90 | + run git alias --local localalias |
| 91 | + assert_output - <<-'EOF' |
| 92 | + localalias = status |
| 93 | +EOF |
| 94 | + assert_success |
| 95 | +} |
| 96 | + |
| 97 | +@test "set alias locally" { |
| 98 | + git alias --local localalias diff |
| 99 | + run git alias |
| 100 | + assert_output - <<-'EOF' |
| 101 | + globalalias = status |
| 102 | + localalias = diff |
| 103 | + x = status |
| 104 | + y = status |
| 105 | +EOF |
| 106 | +} |
0 commit comments