debian-mirror-gitlab/spec/workers/expire_build_instance_artifacts_worker_spec.rb

76 lines
1.9 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2016-11-03 12:29:30 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe ExpireBuildInstanceArtifactsWorker do
2016-11-03 12:29:30 +05:30
include RepoHelpers
let(:worker) { described_class.new }
describe '#perform' do
before do
worker.perform(build.id)
end
context 'with expired artifacts' do
context 'when associated project is valid' do
2018-03-17 18:26:18 +05:30
let(:build) { create(:ci_build, :artifacts, :expired) }
2016-11-03 12:29:30 +05:30
it 'does expire' do
expect(build.reload.artifacts_expired?).to be_truthy
end
it 'does remove files' do
2019-09-04 21:01:54 +05:30
expect(build.reload.artifacts_file.present?).to be_falsey
2016-11-03 12:29:30 +05:30
end
2018-03-17 18:26:18 +05:30
it 'does remove the job artifact record' do
expect(build.reload.job_artifacts_archive).to be_nil
2016-11-03 12:29:30 +05:30
end
end
end
context 'with not yet expired artifacts' do
2020-04-08 14:13:33 +05:30
let_it_be(:build) do
2020-07-28 23:09:34 +05:30
create(:ci_build, :artifacts, artifacts_expire_at: Time.current + 7.days)
2016-11-03 12:29:30 +05:30
end
it 'does not expire' do
expect(build.reload.artifacts_expired?).to be_falsey
end
it 'does not remove files' do
2019-09-04 21:01:54 +05:30
expect(build.reload.artifacts_file.present?).to be_truthy
2016-11-03 12:29:30 +05:30
end
2018-03-17 18:26:18 +05:30
it 'does not remove the job artifact record' do
expect(build.reload.job_artifacts_archive).not_to be_nil
2016-11-03 12:29:30 +05:30
end
end
context 'without expire date' do
let(:build) { create(:ci_build, :artifacts) }
it 'does not expire' do
expect(build.reload.artifacts_expired?).to be_falsey
end
it 'does not remove files' do
2019-09-04 21:01:54 +05:30
expect(build.reload.artifacts_file.present?).to be_truthy
2016-11-03 12:29:30 +05:30
end
2018-03-17 18:26:18 +05:30
it 'does not remove the job artifact record' do
expect(build.reload.job_artifacts_archive).not_to be_nil
2016-11-03 12:29:30 +05:30
end
end
context 'for expired artifacts' do
2018-03-17 18:26:18 +05:30
let(:build) { create(:ci_build, :expired) }
2016-11-03 12:29:30 +05:30
it 'is still expired' do
expect(build.reload.artifacts_expired?).to be_truthy
end
end
end
end