Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildstream
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
BuildStream
buildstream
Commits
01344f51
You need to sign in or sign up before continuing.
Commit
01344f51
authored
6 years ago
by
James Ennis
Browse files
Options
Downloads
Patches
Plain Diff
tests: Add tests for the artifact delete subcommand
parent
3ba9bb50
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/integration/artifact.py
+84
-0
84 additions, 0 deletions
tests/integration/artifact.py
with
84 additions
and
0 deletions
tests/integration/artifact.py
+
84
−
0
View file @
01344f51
...
...
@@ -66,3 +66,87 @@ def test_artifact_log(cli, tmpdir, datafiles):
assert
result
.
exit_code
==
0
# The artifact is cached under both a strong key and a weak key
assert
(
log
+
log
)
==
result
.
output
# Test that we can delete the artifact of the element which corresponds
# to the current project state
@pytest.mark.integration
@pytest.mark.datafiles
(
DATA_DIR
)
def
test_artifact_delete_element
(
cli
,
tmpdir
,
datafiles
):
project
=
os
.
path
.
join
(
datafiles
.
dirname
,
datafiles
.
basename
)
element
=
'
integration.bst
'
# Build the element and ensure it's cached
result
=
cli
.
run
(
project
=
project
,
args
=
[
'
build
'
,
element
])
result
.
assert_success
()
assert
cli
.
get_element_state
(
project
,
element
)
==
'
cached
'
result
=
cli
.
run
(
project
=
project
,
args
=
[
'
artifact
'
,
'
delete
'
,
element
])
result
.
assert_success
()
assert
cli
.
get_element_state
(
project
,
element
)
!=
'
cached
'
# Test that we can delete an artifact by specifying its ref.
@pytest.mark.integration
@pytest.mark.datafiles
(
DATA_DIR
)
def
test_artifact_delete_artifact
(
cli
,
tmpdir
,
datafiles
):
project
=
os
.
path
.
join
(
datafiles
.
dirname
,
datafiles
.
basename
)
element
=
'
integration.bst
'
# Configure a local cache
local_cache
=
os
.
path
.
join
(
str
(
tmpdir
),
'
artifacts
'
)
cli
.
configure
({
'
artifactdir
'
:
local_cache
})
# First build an element so that we can find its artifact
result
=
cli
.
run
(
project
=
project
,
args
=
[
'
build
'
,
element
])
result
.
assert_success
()
# Obtain the artifact ref
cache_key
=
cli
.
get_element_key
(
project
,
element
)
artifact
=
os
.
path
.
join
(
'
test
'
,
os
.
path
.
splitext
(
element
)[
0
],
cache_key
)
# Explicitly check that the ARTIFACT exists in the cache
assert
os
.
path
.
exists
(
os
.
path
.
join
(
local_cache
,
'
cas
'
,
'
refs
'
,
'
heads
'
,
artifact
))
# Delete the artifact
result
=
cli
.
run
(
project
=
project
,
args
=
[
'
artifact
'
,
'
delete
'
,
artifact
])
result
.
assert_success
()
# Check that the ARTIFACT is no longer in the cache
assert
not
os
.
path
.
exists
(
os
.
path
.
join
(
local_cache
,
'
cas
'
,
'
refs
'
,
'
heads
'
,
artifact
))
# Test the `bst artifact delete` command with multiple, different arguments.
@pytest.mark.integration
@pytest.mark.datafiles
(
DATA_DIR
)
def
test_artifact_delete_element_and_artifact
(
cli
,
tmpdir
,
datafiles
):
project
=
os
.
path
.
join
(
datafiles
.
dirname
,
datafiles
.
basename
)
element
=
'
integration.bst
'
dep
=
'
base/base-alpine.bst
'
# Configure a local cache
local_cache
=
os
.
path
.
join
(
str
(
tmpdir
),
'
artifacts
'
)
cli
.
configure
({
'
artifactdir
'
:
local_cache
})
# First build an element so that we can find its artifact
result
=
cli
.
run
(
project
=
project
,
args
=
[
'
build
'
,
element
])
result
.
assert_success
()
assert
cli
.
get_element_state
(
project
,
element
)
==
'
cached
'
assert
cli
.
get_element_state
(
project
,
dep
)
==
'
cached
'
# Obtain the artifact ref
cache_key
=
cli
.
get_element_key
(
project
,
element
)
artifact
=
os
.
path
.
join
(
'
test
'
,
os
.
path
.
splitext
(
element
)[
0
],
cache_key
)
# Explicitly check that the ARTIFACT exists in the cache
assert
os
.
path
.
exists
(
os
.
path
.
join
(
local_cache
,
'
cas
'
,
'
refs
'
,
'
heads
'
,
artifact
))
# Delete the artifact
result
=
cli
.
run
(
project
=
project
,
args
=
[
'
artifact
'
,
'
delete
'
,
artifact
,
dep
])
result
.
assert_success
()
# Check that the ARTIFACT is no longer in the cache
assert
not
os
.
path
.
exists
(
os
.
path
.
join
(
local_cache
,
'
cas
'
,
'
refs
'
,
'
heads
'
,
artifact
))
# Check that the dependency ELEMENT is no longer cached
assert
cli
.
get_element_state
(
project
,
dep
)
!=
'
cached
'
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment