From 583b49f08e5799508d5ebdf7e6f6ccbbe0a0d0bf Mon Sep 17 00:00:00 2001 From: Shinya Maeda <shinya@gitlab.com> Date: Wed, 28 Feb 2018 18:48:08 +0900 Subject: [PATCH] Add spec for workers --- .../archive_legacy_trace_worker_spec.rb | 30 +++++++++++++++++++ .../create_trace_artifact_worker_spec.rb | 6 ++-- 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 spec/workers/archive_legacy_trace_worker_spec.rb diff --git a/spec/workers/archive_legacy_trace_worker_spec.rb b/spec/workers/archive_legacy_trace_worker_spec.rb new file mode 100644 index 00000000000..28b247e3058 --- /dev/null +++ b/spec/workers/archive_legacy_trace_worker_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe ArchiveLegacyTraceWorker do + it { is_expected.to be_a(ObjectStorageQueue) } + it { is_expected.not_to be_a(PipelineQueue) } + + describe '#perform' do + subject { described_class.new.perform(job&.id) } + + context 'when job is found' do + let(:job) { create(:ci_build) } + + it 'executes service' do + expect_any_instance_of(Gitlab::Ci::Trace).to receive(:archive!) + + subject + end + end + + context 'when job is not found' do + let(:job) { nil } + + it 'does not execute service' do + expect_any_instance_of(Gitlab::Ci::Trace).not_to receive(:archive!) + + subject + end + end + end +end diff --git a/spec/workers/create_trace_artifact_worker_spec.rb b/spec/workers/create_trace_artifact_worker_spec.rb index 854abd9cca7..5fc2b183abc 100644 --- a/spec/workers/create_trace_artifact_worker_spec.rb +++ b/spec/workers/create_trace_artifact_worker_spec.rb @@ -8,8 +8,7 @@ describe CreateTraceArtifactWorker do let(:job) { create(:ci_build) } it 'executes service' do - expect_any_instance_of(Ci::CreateTraceArtifactService) - .to receive(:execute).with(job) + expect_any_instance_of(Gitlab::Ci::Trace).to receive(:archive!) subject end @@ -19,8 +18,7 @@ describe CreateTraceArtifactWorker do let(:job) { nil } it 'does not execute service' do - expect_any_instance_of(Ci::CreateTraceArtifactService) - .not_to receive(:execute) + expect_any_instance_of(Gitlab::Ci::Trace).not_to receive(:archive!) subject end -- 2.30.9