Skip to content

Commit f00562c

Browse files
author
Gauvain Pocentek
committed
Make CLI tests work for v4 as well
1 parent f762cf6 commit f00562c

File tree

3 files changed

+203
-87
lines changed

3 files changed

+203
-87
lines changed

tools/cli_test_v3.sh

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
'

tools/cli_test_v4.sh

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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 "verbose output" '
39+
OUTPUT=$(try GITLAB -v user list) || exit 1
40+
pecho "${OUTPUT}" | grep -q avatar-url
41+
'
42+
43+
testcase "CLI args not in output" '
44+
OUTPUT=$(try GITLAB -v user list) || exit 1
45+
pecho "${OUTPUT}" | grep -qv config-file
46+
'
47+
48+
testcase "adding member to a project" '
49+
GITLAB project-member create --project-id "$PROJECT_ID" \
50+
--user-id "$USER_ID" --access-level 40 >/dev/null 2>&1
51+
'
52+
53+
testcase "file creation" '
54+
GITLAB project-file create --project-id "$PROJECT_ID" \
55+
--file-path README --branch master --content "CONTENT" \
56+
--commit-message "Initial commit" >/dev/null 2>&1
57+
'
58+
59+
testcase "issue creation" '
60+
OUTPUT=$(GITLAB project-issue create --project-id "$PROJECT_ID" \
61+
--title "my issue" --description "my issue description")
62+
'
63+
ISSUE_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2)
64+
65+
testcase "note creation" '
66+
GITLAB project-issue-note create --project-id "$PROJECT_ID" \
67+
--issue-id "$ISSUE_ID" --body "the body" >/dev/null 2>&1
68+
'
69+
70+
testcase "branch creation" '
71+
GITLAB project-branch create --project-id "$PROJECT_ID" \
72+
--branch branch1 --ref master >/dev/null 2>&1
73+
'
74+
75+
GITLAB project-file create --project-id "$PROJECT_ID" \
76+
--file-path README2 --branch branch1 --content "CONTENT" \
77+
--commit-message "second commit" >/dev/null 2>&1
78+
79+
testcase "merge request creation" '
80+
OUTPUT=$(GITLAB project-merge-request create \
81+
--project-id "$PROJECT_ID" \
82+
--source-branch branch1 --target-branch master \
83+
--title "Update README")
84+
'
85+
MR_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2)
86+
87+
testcase "merge request validation" '
88+
GITLAB project-merge-request merge --project-id "$PROJECT_ID" \
89+
--id "$MR_ID" >/dev/null 2>&1
90+
'
91+
92+
testcase "branch deletion" '
93+
GITLAB project-branch delete --project-id "$PROJECT_ID" \
94+
--name branch1 >/dev/null 2>&1
95+
'
96+
97+
testcase "project deletion" '
98+
GITLAB project delete --id "$PROJECT_ID"
99+
'

tools/functional_tests.sh

+1-87
Original file line numberDiff line numberDiff line change
@@ -18,90 +18,4 @@ setenv_script=$(dirname "$0")/build_test_env.sh || exit 1
1818
BUILD_TEST_ENV_AUTO_CLEANUP=true
1919
. "$setenv_script" "$@" || exit 1
2020

21-
testcase "project creation" '
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
26-
'
27-
28-
testcase "project update" '
29-
GITLAB project update --id "$PROJECT_ID" --description "My New Description"
30-
'
31-
32-
testcase "user creation" '
33-
OUTPUT=$(GITLAB user create --email fake@email.com --username user1 \
34-
--name "User One" --password fakepassword)
35-
'
36-
USER_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2)
37-
38-
testcase "user get (by id)" '
39-
GITLAB user get --id $USER_ID >/dev/null 2>&1
40-
'
41-
42-
testcase "user get (by username)" '
43-
GITLAB user get-by-username --query user1 >/dev/null 2>&1
44-
'
45-
46-
testcase "verbose output" '
47-
OUTPUT=$(try GITLAB -v user list) || exit 1
48-
pecho "${OUTPUT}" | grep -q avatar-url
49-
'
50-
51-
testcase "CLI args not in output" '
52-
OUTPUT=$(try GITLAB -v user list) || exit 1
53-
pecho "${OUTPUT}" | grep -qv config-file
54-
'
55-
56-
testcase "adding member to a project" '
57-
GITLAB project-member create --project-id "$PROJECT_ID" \
58-
--user-id "$USER_ID" --access-level 40 >/dev/null 2>&1
59-
'
60-
61-
testcase "file creation" '
62-
GITLAB project-file create --project-id "$PROJECT_ID" \
63-
--file-path README --branch-name master --content "CONTENT" \
64-
--commit-message "Initial commit" >/dev/null 2>&1
65-
'
66-
67-
testcase "issue creation" '
68-
OUTPUT=$(GITLAB project-issue create --project-id "$PROJECT_ID" \
69-
--title "my issue" --description "my issue description")
70-
'
71-
ISSUE_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2)
72-
73-
testcase "note creation" '
74-
GITLAB project-issue-note create --project-id "$PROJECT_ID" \
75-
--issue-id "$ISSUE_ID" --body "the body" >/dev/null 2>&1
76-
'
77-
78-
testcase "branch creation" '
79-
GITLAB project-branch create --project-id "$PROJECT_ID" \
80-
--branch-name branch1 --ref master >/dev/null 2>&1
81-
'
82-
83-
GITLAB project-file create --project-id "$PROJECT_ID" \
84-
--file-path README2 --branch-name branch1 --content "CONTENT" \
85-
--commit-message "second commit" >/dev/null 2>&1
86-
87-
testcase "merge request creation" '
88-
OUTPUT=$(GITLAB project-merge-request create \
89-
--project-id "$PROJECT_ID" \
90-
--source-branch branch1 --target-branch master \
91-
--title "Update README")
92-
'
93-
MR_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2)
94-
95-
testcase "merge request validation" '
96-
GITLAB project-merge-request merge --project-id "$PROJECT_ID" \
97-
--id "$MR_ID" >/dev/null 2>&1
98-
'
99-
100-
testcase "branch deletion" '
101-
GITLAB project-branch delete --project-id "$PROJECT_ID" \
102-
--name branch1 >/dev/null 2>&1
103-
'
104-
105-
testcase "project deletion" '
106-
GITLAB project delete --id "$PROJECT_ID"
107-
'
21+
. $(dirname "$0")/cli_test_v${API_VER}.sh

0 commit comments

Comments
 (0)