-
Notifications
You must be signed in to change notification settings - Fork 2
/
git-bulk-tests.sh
98 lines (84 loc) · 4.42 KB
/
git-bulk-tests.sh
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
#!/bin/sh
function finish {
cp ~/.gitconfigbak ~/.gitconfig # restore git config
rm ~/.gitconfigbak
}
trap finish EXIT
cp ~/.gitconfig ~/.gitconfigbak # save git config
source ../bashunit/bashunit.sh
standardout=false
git config --global --remove-section bulkworkspaces
# test wrong GIT commands
assertContains "bash git-bulk.sh --addworkspac carriertech /Users/niklasschlimm/workspaces/carriertech" "unknown"
assertContains "bash git-bulk.sh wedfwe wefwefwf" "unknown GIT"
assertContains "bash git-bulk.sh wefwefwf" "unknown GIT"
assertContains "bash git-bulk.sh -h" "unknown argument"
assertContains "bash git-bulk.sh --h" "unknown argument"
# test worng usage of options and argument count
assertContains "bash git-bulk.sh --addworkspace bla carriertech /Users/niklasschlimm/workspaces/carriertech" "wrong number"
assertContains "bash git-bulk.sh --addworkspace bla" "wrong number"
assertContains "bash git-bulk.sh --addworkspace" "wrong number"
assertContains "bash git-bulk.sh --addworkspace carriertech /Users/niklasschlimm/workspaces/carriertech xqsxq" "wrong number"
assertContains "bash git-bulk.sh --removeworkspace bla carriertech" "wrong number"
assertContains "bash git-bulk.sh --removeworkspace" "wrong number"
assertContains "bash git-bulk.sh --removeworkspace carriertech /Users/niklasschlimm/workspaces/carriertech xqsxq" "wrong number"
assertContains "bash git-bulk.sh --addcurrent bla carriertech" "wrong number"
assertContains "bash git-bulk.sh --addcurrent" "wrong number"
assertContains "bash git-bulk.sh --addcurrent carriertech /Users/niklasschlimm/workspaces/carriertech xqsxq" "wrong number"
assertContains "bash git-bulk.sh --listall carriertech" "wrong number"
assertContains "bash git-bulk.sh --purge carriertech" "wrong number"
assertContains "bash git-bulk.sh -g -h ss ss" "unknown argument"
assertContains "bash git-bulk.sh -g --listall" "wrong number"
assertContains "bash git-bulk.sh --bla" "unknown argument"
assertContains "bash git-bulk.sh -w -g personal status -s" "unknown workspace"
# test correct workspace administration
assertCheckContains "bash git-bulk.sh --addworkspace testws1 bla" "git config --global --get-regexp bulkworkspaces" "bla"
assertCheckContains "bash git-bulk.sh --addworkspace testws2 blub" "git config --global --get-regexp bulkworkspaces" "blub"
assertCheckNotContains "bash git-bulk.sh --removeworkspace testws1" "git config --global --get-regexp bulkworkspaces" "testws1"
assertCheckContains "bash git-bulk.sh --addcurrent testws" "git config --global --get-regexp bulkworkspaces" "testws"
# correct git command
assertContains "bash git-bulk.sh status -s" "executing"
assertContains "bash git-bulk.sh -a status -s" "executing"
# tests with bulk commands on workspaces
git config --global bulkworkspaces.testws1 "~/workspaces/personal"
git config --global bulkworkspaces.testws2 "~/workspaces/community"
assertContains "bash git-bulk.sh -w testws2 status -s" "workspaces/community"
assertContains "bash git-bulk.sh -a status -s" "workspaces/personal"
assertContains "bash git-bulk.sh status -s" "workspaces/personal"
assertContains "bash git-bulk.sh -a status -s" "workspaces/community"
assertContains "bash git-bulk.sh -w testws2 -a" "incompatible"
cd ..
assertContains "bash git-bulk/git-bulk.sh status -s" "you are not"
cd git-bulk/
git config --global --remove-section bulkworkspaces
assertContains "bash git-bulk.sh -w persona status -s" "unknown workspace name"
# test correct listing of repos
git config --global bulkworkspaces.testws "testdir"
assertContains "bash git-bulk.sh --listall" "testws"
git config --global --remove-section bulkworkspaces
# test purge success
git config --global bulkworkspaces.testws "testdir"
assertContains "git config --global --get-regexp bulkworkspaces" "testws"
assertCheckContains "bash git-bulk.sh --purge" "git config --global --get-regexp bulkworkspaces" "^$"
# path with whitespace in repositors location
mkdir "test test"
cd "test test"
git init 1>/dev/null
cd ..
git bulk --addcurrent testws
assertContains "git bulk status -s" "test test"
rm -rf "test test"
# path with whitespace in workspace location
curdir=$(pwd)
cd ~/workspaces
mkdir "test ws"
cd "test ws"
mkdir "testrepo1" && cd "testrepo1" && git init 1>/dev/null && cd ..
mkdir "testrepo2" && cd "testrepo2" && git init 1>/dev/null && cd ..
git bulk --addcurrent testws
assertContains "git bulk status -s" "testrepo1"
cd ..
rm -rf "test ws"
cd "$curdir"
testend "git bulk tests"
cp ~/.gitconfigbak ~/.gitconfig # restore git config