|
| 1 | +#!/bin/sh |
| 2 | +# Copyright (C) 2015 Gauvain Pocentek <gauvain@pocentek.net> |
| 3 | +# |
| 4 | +# This program is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU Lesser General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU Lesser General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU Lesser General Public License |
| 15 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +testcase "project creation" ' |
| 18 | + OUTPUT=$(try GITLAB project create --name test-project1) || exit 1 |
| 19 | + PROJECT_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d" " -f2) |
| 20 | + OUTPUT=$(try GITLAB project list) || exit 1 |
| 21 | + pecho "${OUTPUT}" | grep -q test-project1 |
| 22 | +' |
| 23 | + |
| 24 | +testcase "project update" ' |
| 25 | + GITLAB project update --id "$PROJECT_ID" --description "My New Description" |
| 26 | +' |
| 27 | + |
| 28 | +testcase "user creation" ' |
| 29 | + OUTPUT=$(GITLAB user create --email fake@email.com --username user1 \ |
| 30 | + --name "User One" --password fakepassword) |
| 31 | +' |
| 32 | +USER_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2) |
| 33 | + |
| 34 | +testcase "user get (by id)" ' |
| 35 | + GITLAB user get --id $USER_ID >/dev/null 2>&1 |
| 36 | +' |
| 37 | + |
| 38 | +testcase "user get (by username)" ' |
| 39 | + GITLAB user get-by-username --query user1 >/dev/null 2>&1 |
| 40 | +' |
| 41 | + |
| 42 | +testcase "verbose output" ' |
| 43 | + OUTPUT=$(try GITLAB -v user list) || exit 1 |
| 44 | + pecho "${OUTPUT}" | grep -q avatar-url |
| 45 | +' |
| 46 | + |
| 47 | +testcase "CLI args not in output" ' |
| 48 | + OUTPUT=$(try GITLAB -v user list) || exit 1 |
| 49 | + pecho "${OUTPUT}" | grep -qv config-file |
| 50 | +' |
| 51 | + |
| 52 | +testcase "adding member to a project" ' |
| 53 | + GITLAB project-member create --project-id "$PROJECT_ID" \ |
| 54 | + --user-id "$USER_ID" --access-level 40 >/dev/null 2>&1 |
| 55 | +' |
| 56 | + |
| 57 | +testcase "file creation" ' |
| 58 | + GITLAB project-file create --project-id "$PROJECT_ID" \ |
| 59 | + --file-path README --branch-name master --content "CONTENT" \ |
| 60 | + --commit-message "Initial commit" >/dev/null 2>&1 |
| 61 | +' |
| 62 | + |
| 63 | +testcase "issue creation" ' |
| 64 | + OUTPUT=$(GITLAB project-issue create --project-id "$PROJECT_ID" \ |
| 65 | + --title "my issue" --description "my issue description") |
| 66 | +' |
| 67 | +ISSUE_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2) |
| 68 | + |
| 69 | +testcase "note creation" ' |
| 70 | + GITLAB project-issue-note create --project-id "$PROJECT_ID" \ |
| 71 | + --issue-id "$ISSUE_ID" --body "the body" >/dev/null 2>&1 |
| 72 | +' |
| 73 | + |
| 74 | +testcase "branch creation" ' |
| 75 | + GITLAB project-branch create --project-id "$PROJECT_ID" \ |
| 76 | + --branch-name branch1 --ref master >/dev/null 2>&1 |
| 77 | +' |
| 78 | + |
| 79 | +GITLAB project-file create --project-id "$PROJECT_ID" \ |
| 80 | + --file-path README2 --branch-name branch1 --content "CONTENT" \ |
| 81 | + --commit-message "second commit" >/dev/null 2>&1 |
| 82 | + |
| 83 | +testcase "merge request creation" ' |
| 84 | + OUTPUT=$(GITLAB project-merge-request create \ |
| 85 | + --project-id "$PROJECT_ID" \ |
| 86 | + --source-branch branch1 --target-branch master \ |
| 87 | + --title "Update README") |
| 88 | +' |
| 89 | +MR_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2) |
| 90 | + |
| 91 | +testcase "merge request validation" ' |
| 92 | + GITLAB project-merge-request merge --project-id "$PROJECT_ID" \ |
| 93 | + --id "$MR_ID" >/dev/null 2>&1 |
| 94 | +' |
| 95 | + |
| 96 | +testcase "branch deletion" ' |
| 97 | + GITLAB project-branch delete --project-id "$PROJECT_ID" \ |
| 98 | + --name branch1 >/dev/null 2>&1 |
| 99 | +' |
| 100 | + |
| 101 | +testcase "project deletion" ' |
| 102 | + GITLAB project delete --id "$PROJECT_ID" |
| 103 | +' |
0 commit comments