Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-runner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Seipel
gitlab-runner
Commits
7514fd2e
Commit
7514fd2e
authored
7 years ago
by
Paul B
Browse files
Options
Downloads
Patches
Plain Diff
test: Add a failing test on artifact upload error
parent
0a0ae247
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
common/build_test.go
+45
-0
45 additions, 0 deletions
common/build_test.go
with
45 additions
and
0 deletions
common/build_test.go
+
45
−
0
View file @
7514fd2e
...
@@ -267,6 +267,51 @@ func TestArtifactDownloadRunFailure(t *testing.T) {
...
@@ -267,6 +267,51 @@ func TestArtifactDownloadRunFailure(t *testing.T) {
assert
.
EqualError
(
t
,
err
,
"build fail"
)
assert
.
EqualError
(
t
,
err
,
"build fail"
)
}
}
func
TestArtifactUploadRunFailure
(
t
*
testing
.
T
)
{
e
:=
MockExecutor
{}
defer
e
.
AssertExpectations
(
t
)
p
:=
MockExecutorProvider
{}
defer
p
.
AssertExpectations
(
t
)
// Create executor
p
.
On
(
"Create"
)
.
Return
(
&
e
)
.
Once
()
// Prepare plan
e
.
On
(
"Prepare"
,
mock
.
Anything
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
nil
)
e
.
On
(
"Cleanup"
)
.
Return
()
// Successful build script
e
.
On
(
"Shell"
)
.
Return
(
&
ShellScriptInfo
{
Shell
:
"script-shell"
})
.
Times
(
8
)
e
.
On
(
"Run"
,
mock
.
Anything
)
.
Return
(
nil
)
.
Times
(
7
)
// Fail last stage (upload stage)
e
.
On
(
"Run"
,
mock
.
Anything
)
.
Return
(
errors
.
New
(
"upload fail"
))
.
Once
()
e
.
On
(
"Finish"
,
errors
.
New
(
"upload fail"
))
.
Return
()
.
Once
()
RegisterExecutor
(
"build-upload-artifacts-run-failure"
,
&
p
)
successfulBuild
,
err
:=
GetSuccessfulBuild
()
successfulBuild
.
Artifacts
=
make
(
Artifacts
,
1
)
successfulBuild
.
Artifacts
[
0
]
=
Artifact
{
Name
:
"my-artifact"
,
Untracked
:
false
,
Paths
:
ArtifactPaths
{
"cached/*"
},
When
:
ArtifactWhenAlways
,
}
assert
.
NoError
(
t
,
err
)
build
:=
&
Build
{
JobResponse
:
successfulBuild
,
Runner
:
&
RunnerConfig
{
RunnerSettings
:
RunnerSettings
{
Executor
:
"build-upload-artifacts-run-failure"
,
},
},
}
err
=
build
.
Run
(
&
Config
{},
&
Trace
{
Writer
:
os
.
Stdout
})
assert
.
EqualError
(
t
,
err
,
"upload fail"
)
}
func
TestRestoreCacheRunFailure
(
t
*
testing
.
T
)
{
func
TestRestoreCacheRunFailure
(
t
*
testing
.
T
)
{
e
:=
MockExecutor
{}
e
:=
MockExecutor
{}
defer
e
.
AssertExpectations
(
t
)
defer
e
.
AssertExpectations
(
t
)
...
...
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