Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-02-28 12:43:19 +0300
committerShinya Maeda <shinya@gitlab.com>2018-03-06 15:43:19 +0300
commit824af79d64b8be277dbddad0936c2b7b8237ce5d (patch)
tree23fdd97074bfb8fa6491f0dc0fc7f16402dc8b0e /spec/tasks
parent91117452e1c106352171aea56ef336dbafd322a6 (diff)
Fix rake task to use corrrect SQL
Diffstat (limited to 'spec/tasks')
-rw-r--r--spec/tasks/gitlab/traces_rake_spec.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/tasks/gitlab/traces_rake_spec.rb b/spec/tasks/gitlab/traces_rake_spec.rb
new file mode 100644
index 00000000000..d2eaa88f287
--- /dev/null
+++ b/spec/tasks/gitlab/traces_rake_spec.rb
@@ -0,0 +1,55 @@
+require 'rake_helper'
+
+describe 'gitlab:traces rake tasks' do
+ before do
+ Rake.application.rake_require 'tasks/gitlab/traces'
+ end
+
+ shared_examples 'passes the job id to worker' do
+ it do
+ expect(ArchiveLegacyTraceWorker).to receive(:bulk_perform_async).with([[job.id]])
+
+ run_rake_task('gitlab:traces:archive')
+ end
+ end
+
+ shared_examples 'does not pass the job id to worker' do
+ it do
+ expect(ArchiveLegacyTraceWorker).not_to receive(:bulk_perform_async)
+
+ run_rake_task('gitlab:traces:archive')
+ end
+ end
+
+ context 'when trace file stored in default path' do
+ let!(:job) { create(:ci_build, :success, :trace_live) }
+
+ it_behaves_like 'passes the job id to worker'
+ end
+
+ context 'when trace is stored in database' do
+ let!(:job) { create(:ci_build, :success) }
+
+ before do
+ job.update_column(:trace, 'trace in db')
+ end
+
+ it_behaves_like 'passes the job id to worker'
+ end
+
+ context 'when job has trace artifact' do
+ let!(:job) { create(:ci_build, :success) }
+
+ before do
+ create(:ci_job_artifact, :trace, job: job)
+ end
+
+ it_behaves_like 'does not pass the job id to worker'
+ end
+
+ context 'when job is not finished yet' do
+ let!(:build) { create(:ci_build, :running, :trace_live) }
+
+ it_behaves_like 'does not pass the job id to worker'
+ end
+end