Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8f1f73d4
Commit
8f1f73d4
authored
Jun 04, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix typo in spec. Add a test for the case of when trace is stored in database
parent
2184c753
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
4 deletions
+26
-4
spec/lib/gitlab/background_migration/archive_legacy_traces_spec.rb
...gitlab/background_migration/archive_legacy_traces_spec.rb
+22
-4
spec/support/trace/trace_helpers.rb
spec/support/trace/trace_helpers.rb
+4
-0
No files found.
spec/lib/gitlab/background_migration/archive_legacy_traces_spec.rb
View file @
8f1f73d4
...
...
@@ -16,7 +16,7 @@ describe Gitlab::BackgroundMigration::ArchiveLegacyTraces, :migration, schema: 2
context
'when trace file exsits at the right place'
do
before
do
create_legacy_trace
(
@build
,
'
aiueo
'
)
create_legacy_trace
(
@build
,
'
trace in file
'
)
end
it
'correctly archive legacy traces'
do
...
...
@@ -27,15 +27,33 @@ describe Gitlab::BackgroundMigration::ArchiveLegacyTraces, :migration, schema: 2
expect
(
job_artifacts
.
count
).
to
eq
(
1
)
expect
(
File
.
exist?
(
legacy_trace_path
(
@build
))).
to
be_falsy
expect
(
File
.
read
(
archived_trace_path
(
job_artifacts
.
first
))).
to
eq
(
'
aiueo
'
)
expect
(
File
.
read
(
archived_trace_path
(
job_artifacts
.
first
))).
to
eq
(
'
trace in file
'
)
end
end
context
'when trace file does not exsits at the right place'
do
it
'does not raise errors
and create job artifact row
'
do
described_class
.
new
.
perform
(
1
,
1
)
it
'does not raise errors
nor create job artifact
'
do
expect
{
described_class
.
new
.
perform
(
1
,
1
)
}.
not_to
raise_error
expect
(
job_artifacts
.
count
).
to
eq
(
0
)
end
end
context
'when trace data exsits in database'
do
before
do
create_legacy_trace_in_db
(
@build
,
'trace in db'
)
end
it
'correctly archive legacy traces'
do
expect
(
job_artifacts
.
count
).
to
eq
(
0
)
expect
(
@build
.
read_attribute
(
:trace
)).
not_to
be_empty
described_class
.
new
.
perform
(
1
,
1
)
@build
.
reload
expect
(
job_artifacts
.
count
).
to
eq
(
1
)
expect
(
@build
.
read_attribute
(
:trace
)).
to
be_nil
expect
(
File
.
read
(
archived_trace_path
(
job_artifacts
.
first
))).
to
eq
(
'trace in db'
)
end
end
end
spec/support/trace/trace_helpers.rb
View file @
8f1f73d4
...
...
@@ -3,6 +3,10 @@ module TraceHelpers
File
.
open
(
legacy_trace_path
(
build
),
'wb'
)
{
|
stream
|
stream
.
write
(
content
)
}
end
def
create_legacy_trace_in_db
(
build
,
content
)
build
.
update_column
(
:trace
,
content
)
end
def
legacy_trace_path
(
build
)
legacy_trace_dir
=
File
.
join
(
Settings
.
gitlab_ci
.
builds_path
,
build
.
created_at
.
utc
.
strftime
(
"%Y_%m"
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment