Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1bc412e

Browse files
author
Gauvain Pocentek
committed
Provide a basic functional test script
This can be used to quickly test the correct behavior of the CLI. Thescript is simple and doesn't test much for now, but it's a start.
1 parentaae8e2d commit1bc412e

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

‎tools/functional_tests.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
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+
cleanup() {
18+
rm -f /tmp/python-gitlab.cfg
19+
dockerkill gitlab-test>/dev/null2>&1
20+
docker rm gitlab-test>/dev/null2>&1
21+
}
22+
trap cleanup EXIT
23+
24+
docker run --name gitlab-test --detach --publish 8080:80 --publish 2222:22 sytse/gitlab-ce:7.10.1>/dev/null2>&1
25+
26+
LOGIN='root'
27+
PASSWORD='5iveL!fe'
28+
CONFIG=/tmp/python-gitlab.cfg
29+
GITLAB="gitlab --config-file$CONFIG"
30+
31+
GREEN='\033[0;32m'
32+
NC='\033[0m'
33+
OK="echo -e${GREEN}OK${NC}"
34+
35+
echo -n"Waiting for gitlab to come online..."
36+
I=0
37+
while:;do
38+
sleep 5
39+
curl -s http://localhost:8080/users/sign_in2>/dev/null| grep -q"GitLab Community Edition"&&break
40+
let I=I+5
41+
[$I-eq 120 ]&&exit 1
42+
done
43+
sleep 5
44+
$OK
45+
46+
# Get the token
47+
TOKEN=$(curl -s http://localhost:8080/api/v3/session \
48+
-X POST \
49+
--data"login=$LOGIN&password=$PASSWORD" \
50+
| python -c'import sys, json; print json.load(sys.stdin)["private_token"]')
51+
52+
cat>$CONFIG<<EOF
53+
[global]
54+
default = local
55+
timeout = 2
56+
57+
[local]
58+
url = http://localhost:8080
59+
private_token =$TOKEN
60+
EOF
61+
62+
echo"Config file content ($CONFIG):"
63+
cat$CONFIG
64+
65+
# NOTE(gpocentek): the first call might fail without a little delay
66+
sleep 10
67+
68+
set -e
69+
70+
echo -n"Testing project creation..."
71+
PROJECT_ID=$($GITLAB project create --name test-project1| grep ^id:| cut -d'' -f2)
72+
$GITLAB project list| grep -q test-project1
73+
$OK
74+
75+
echo -n"Testing user creation..."
76+
USER_ID=$($GITLAB user create --email fake@email.com --username user1 --name"User One" --password fakepassword| grep ^id:| cut -d'' -f2)
77+
$OK
78+
79+
echo -n"Testing verbose output..."
80+
$GITLAB user list| grep -q avatar-url
81+
$OK
82+
83+
echo -n"Testing CLI args not in output..."
84+
$GITLAB user list| grep -v config-file
85+
$OK
86+
87+
echo -n"Testing adding member to a project..."
88+
$GITLAB project-member create --project-id$PROJECT_ID --user-id$USER_ID --access-level 40>/dev/null2>&1
89+
$OK

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp