|
14 | 14 | # You should have received a copy of the GNU Lesser General Public License
|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16 | 16 |
|
17 |
| -setenv_script=$(dirname "$0")/build_test_env.sh |
| 17 | +setenv_script=$(dirname "$0")/build_test_env.sh || exit 1 |
18 | 18 | BUILD_TEST_ENV_AUTO_CLEANUP=true
|
19 |
| -. "$setenv_script" "$@" |
20 |
| - |
21 |
| -set -e |
| 19 | +. "$setenv_script" "$@" || exit 1 |
22 | 20 |
|
23 | 21 | printf %s "Testing project creation... "
|
24 |
| -PROJECT_ID=$(GITLAB project create --name test-project1 \ |
25 |
| - | grep ^id: | cut -d' ' -f2) |
26 |
| -GITLAB project list | grep -q test-project1 |
| 22 | +OUTPUT=$(try GITLAB project create --name test-project1) || exit 1 |
| 23 | +PROJECT_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2) |
| 24 | +OUTPUT=$(try GITLAB project list) || exit 1 |
| 25 | +pecho "${OUTPUT}" | grep -q test-project1 || fatal "test failed" |
27 | 26 | OK
|
28 | 27 |
|
29 | 28 | printf %s "Testing project update... "
|
30 |
| -GITLAB project update --id "$PROJECT_ID" --description "My New Description" |
| 29 | +GITLAB project update --id "$PROJECT_ID" --description "My New Description" \ |
| 30 | + || fatal "test failed" |
31 | 31 | OK
|
32 | 32 |
|
33 | 33 | printf %s "Testing user creation... "
|
34 |
| -USER_ID=$(GITLAB user create --email fake@email.com --username user1 \ |
35 |
| - --name "User One" --password fakepassword | grep ^id: | cut -d' ' -f2) |
| 34 | +OUTPUT=$(GITLAB user create --email fake@email.com --username user1 \ |
| 35 | + --name "User One" --password fakepassword) || fatal "test failed" |
36 | 36 | OK
|
| 37 | +USER_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2) |
37 | 38 |
|
38 | 39 | printf %s "Testing verbose output... "
|
39 |
| -GITLAB -v user list | grep -q avatar-url |
| 40 | +OUTPUT=$(try GITLAB -v user list) || exit 1 |
| 41 | +pecho "${OUTPUT}" | grep -q avatar-url || fatal "test failed" |
40 | 42 | OK
|
41 | 43 |
|
42 | 44 | printf %s "Testing CLI args not in output... "
|
43 |
| -GITLAB -v user list | grep -qv config-file |
| 45 | +OUTPUT=$(try GITLAB -v user list) || exit 1 |
| 46 | +pecho "${OUTPUT}" | grep -qv config-file || fatal "test failed" |
44 | 47 | OK
|
45 | 48 |
|
46 | 49 | printf %s "Testing adding member to a project... "
|
47 | 50 | GITLAB project-member create --project-id "$PROJECT_ID" \
|
48 |
| - --user-id "$USER_ID" --access-level 40 >/dev/null 2>&1 |
| 51 | + --user-id "$USER_ID" --access-level 40 >/dev/null 2>&1 \ |
| 52 | + || fatal "test failed" |
49 | 53 | OK
|
50 | 54 |
|
51 | 55 | printf %s "Testing file creation... "
|
52 | 56 | GITLAB project-file create --project-id "$PROJECT_ID" \
|
53 | 57 | --file-path README --branch-name master --content "CONTENT" \
|
54 |
| - --commit-message "Initial commit" >/dev/null 2>&1 |
| 58 | + --commit-message "Initial commit" >/dev/null 2>&1 || fatal "test failed" |
55 | 59 | OK
|
56 | 60 |
|
57 | 61 | printf %s "Testing issue creation... "
|
58 |
| -ISSUE_ID=$(GITLAB project-issue create --project-id "$PROJECT_ID" \ |
59 |
| - --title "my issue" --description "my issue description" \ |
60 |
| - | grep ^id: | cut -d' ' -f2) |
| 62 | +OUTPUT=$(GITLAB project-issue create --project-id "$PROJECT_ID" \ |
| 63 | + --title "my issue" --description "my issue description") \ |
| 64 | + || fatal "test failed" |
61 | 65 | OK
|
| 66 | +ISSUE_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2) |
62 | 67 |
|
63 | 68 | printf %s "Testing note creation... "
|
64 | 69 | GITLAB project-issue-note create --project-id "$PROJECT_ID" \
|
65 |
| - --issue-id "$ISSUE_ID" --body "the body" >/dev/null 2>&1 |
| 70 | + --issue-id "$ISSUE_ID" --body "the body" >/dev/null 2>&1 \ |
| 71 | + || fatal "test failed" |
66 | 72 | OK
|
67 | 73 |
|
68 | 74 | printf %s "Testing branch creation... "
|
69 | 75 | GITLAB project-branch create --project-id "$PROJECT_ID" \
|
70 |
| - --branch-name branch1 --ref master >/dev/null 2>&1 |
| 76 | + --branch-name branch1 --ref master >/dev/null 2>&1 || fatal "test failed" |
71 | 77 | OK
|
72 | 78 |
|
73 | 79 | printf %s "Testing branch deletion... "
|
74 | 80 | GITLAB project-branch delete --project-id "$PROJECT_ID" \
|
75 |
| - --name branch1 >/dev/null 2>&1 |
| 81 | + --name branch1 >/dev/null 2>&1 || fatal "test failed" |
76 | 82 | OK
|
77 | 83 |
|
78 | 84 | printf %s "Testing project deletion... "
|
79 |
| -GITLAB project delete --id "$PROJECT_ID" |
| 85 | +GITLAB project delete --id "$PROJECT_ID" || fatal "test failed" |
80 | 86 | OK
|
0 commit comments