| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,7 +48,7 @@ do | |||
| 48 | 48 | command -v "${req}" >/dev/null 2>&1 || fatal "${req} is required" | |
| 49 | 49 | done | |
| 50 | 50 | ||
| 51 | - VENV=$(pwd)/.venv | ||
| 51 | + VENV=$(pwd)/.venv || exit 1 | ||
| 52 | 52 | ||
| 53 | 53 | cleanup() { | |
| 54 | 54 | rm -f /tmp/python-gitlab.cfg | |
@@ -62,7 +62,7 @@ cleanup() { | |||
| 62 | 62 | trap 'exit 1' HUP INT TERM | |
| 63 | 63 | } | |
| 64 | 64 | ||
| 65 | - docker run --name gitlab-test --detach --publish 8080:80 \ | ||
| 65 | + try docker run --name gitlab-test --detach --publish 8080:80 \ | ||
| 66 | 66 | --publish 2222:22 gpocentek/test-python-gitlab:latest >/dev/null 2>&1 | |
| 67 | 67 | ||
| 68 | 68 | LOGIN='root' | |
@@ -87,11 +87,16 @@ done | |||
| 87 | 87 | sleep 5 | |
| 88 | 88 | ||
| 89 | 89 | # Get the token | |
| 90 | - TOKEN=$(curl -s http://localhost:8080/api/v3/session \ | ||
| 91 | - -X POST \ | ||
| 92 | - --data "login=$LOGIN&password=$PASSWORD" \ | ||
| 93 | - | python -c \ | ||
| 94 | - 'import sys, json; print(json.load(sys.stdin)["private_token"])') | ||
| 90 | + TOKEN_JSON=$( | ||
| 91 | + try curl -s http://localhost:8080/api/v3/session \ | ||
| 92 | + -X POST \ | ||
| 93 | + --data "login=$LOGIN&password=$PASSWORD" | ||
| 94 | + ) || exit 1 | ||
| 95 | + TOKEN=$( | ||
| 96 | + pecho "${TOKEN_JSON}" | | ||
| 97 | + try python -c \ | ||
| 98 | + 'import sys, json; print(json.load(sys.stdin)["private_token"])' | ||
| 99 | + ) || exit 1 | ||
| 95 | 100 | ||
| 96 | 101 | cat > $CONFIG << EOF | |
| 97 | 102 | [global] | |
@@ -106,9 +111,9 @@ EOF | |||
| 106 | 111 | log "Config file content ($CONFIG):" | |
| 107 | 112 | log <$CONFIG | |
| 108 | 113 | ||
| 109 | - "$VENV_CMD" "$VENV" | ||
| 110 | - . "$VENV"/bin/activate | ||
| 111 | - pip install -rrequirements.txt | ||
| 112 | - pip install -e . | ||
| 114 | + try "$VENV_CMD" "$VENV" | ||
| 115 | + . "$VENV"/bin/activate || fatal "failed to activate Python virtual environment" | ||
| 116 | + try pip install -rrequirements.txt | ||
| 117 | + try pip install -e . | ||
| 113 | 118 | ||
| 114 | 119 | sleep 20 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,67 +14,73 @@ | |||
| 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 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,8 @@ | |||
| 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" "$@" | ||
| 19 | + . "$setenv_script" "$@" || exit 1 | ||
| 20 | 20 | ||
| 21 | - python "$(dirname "$0")"/python_test.py | ||
| 21 | + try python "$(dirname "$0")"/python_test.py | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments