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

Commit595f64a

Browse files
committed
test(cli): add test for job artifacts download
1 parent111a13e commit595f64a

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
importsubprocess
2+
importsys
3+
importtextwrap
4+
importtime
5+
fromioimportBytesIO
6+
fromzipfileimportis_zipfile
7+
8+
importpytest
9+
10+
11+
content=textwrap.dedent(
12+
"""\
13+
test-artifact:
14+
script: echo "test" > artifact.txt
15+
artifacts:
16+
untracked: true
17+
"""
18+
)
19+
data= {
20+
"file_path":".gitlab-ci.yml",
21+
"branch":"master",
22+
"content":content,
23+
"commit_message":"Initial commit",
24+
}
25+
26+
27+
@pytest.mark.skipif(sys.version_info< (3,8),reason="I am the walrus")
28+
deftest_cli_artifacts(capsysbinary,gitlab_config,gitlab_runner,project):
29+
project.files.create(data)
30+
31+
whilenot (jobs:=project.jobs.list(scope="success")):
32+
time.sleep(0.5)
33+
34+
job=project.jobs.get(jobs[0].id)
35+
cmd= [
36+
"gitlab",
37+
"--config-file",
38+
gitlab_config,
39+
"project-job",
40+
"artifacts",
41+
"--id",
42+
str(job.id),
43+
"--project-id",
44+
str(project.id),
45+
]
46+
47+
withcapsysbinary.disabled():
48+
artifacts=subprocess.check_output(cmd)
49+
assertisinstance(artifacts,bytes)
50+
51+
artifacts_zip=BytesIO(artifacts)
52+
assertis_zipfile(artifacts_zip)

‎tools/functional/conftest.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,34 @@ def gl(gitlab_config):
132132
returninstance
133133

134134

135+
@pytest.fixture(scope="session")
136+
defgitlab_runner(gl):
137+
container="gitlab-runner-test"
138+
runner_name="python-gitlab-runner"
139+
token="registration-token"
140+
url="http://gitlab"
141+
142+
docker_exec= ["docker","exec",container,"gitlab-runner"]
143+
register= [
144+
"register",
145+
"--run-untagged",
146+
"--non-interactive",
147+
"--registration-token",
148+
token,
149+
"--name",
150+
runner_name,
151+
"--url",
152+
url,
153+
"--executor",
154+
"shell",
155+
]
156+
unregister= ["unregister","--name",runner_name]
157+
158+
yieldcheck_output(docker_exec+register).decode()
159+
160+
check_output(docker_exec+unregister).decode()
161+
162+
135163
@pytest.fixture(scope="module")
136164
defgroup(gl):
137165
"""Group fixture for group API resource tests."""

‎tools/functional/fixtures/docker-compose.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
version:'3'
2+
3+
networks:
4+
gitlab-network:
5+
name:gitlab-network
6+
27
services:
38
gitlab:
49
image:'${GITLAB_IMAGE}:${GITLAB_TAG}'
@@ -9,7 +14,7 @@ services:
914
GITLAB_OMNIBUS_CONFIG:|
1015
external_url 'http://gitlab.test'
1116
gitlab_rails['initial_root_password'] = '5iveL!fe'
12-
gitlab_rails['initial_shared_runners_registration_token'] = 'sTPNtWLEuSrHzoHP8oCU'
17+
gitlab_rails['initial_shared_runners_registration_token'] = 'registration-token'
1318
registry['enable'] =false
1419
nginx['redirect_http_to_https'] =false
1520
nginx['listen_port'] = 80
@@ -29,3 +34,13 @@ services:
2934
ports:
3035
-'8080:80'
3136
-'2222:22'
37+
networks:
38+
-gitlab-network
39+
40+
gitlab-runner:
41+
image:gitlab/gitlab-runner:latest
42+
container_name:'gitlab-runner-test'
43+
depends_on:
44+
-gitlab
45+
networks:
46+
-gitlab-network

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp