2016-06-10 15:27:49 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ExpireBuildArtifactsWorker do
|
|
|
|
include RepoHelpers
|
|
|
|
|
2016-06-10 19:45:06 +00:00
|
|
|
let(:worker) { described_class.new }
|
2016-06-10 15:27:49 +00:00
|
|
|
|
|
|
|
describe '#perform' do
|
2016-06-13 14:05:23 +00:00
|
|
|
before { build }
|
2016-06-10 15:27:49 +00:00
|
|
|
|
2016-06-13 14:05:23 +00:00
|
|
|
subject! { worker.perform }
|
2016-06-10 19:45:06 +00:00
|
|
|
|
2016-06-13 14:05:23 +00:00
|
|
|
context 'with expired artifacts' do
|
|
|
|
let!(:build) { create(:ci_build, :artifacts, artifacts_expire_at: Time.now - 7.days) }
|
2016-06-10 19:45:06 +00:00
|
|
|
|
2016-06-13 14:05:23 +00:00
|
|
|
it 'does expire' do
|
2016-06-10 19:45:06 +00:00
|
|
|
expect(build.reload.artifacts_expired?).to be_truthy
|
2016-06-10 15:27:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with not yet expired artifacts' do
|
|
|
|
let!(:build) { create(:ci_build, :artifacts, artifacts_expire_at: Time.now + 7.days) }
|
|
|
|
|
2016-06-13 14:05:23 +00:00
|
|
|
it 'does not expire' do
|
|
|
|
expect(build.reload.artifacts_expired?).to be_truthy
|
2016-06-10 15:27:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without expire date' do
|
|
|
|
let!(:build) { create(:ci_build, :artifacts) }
|
|
|
|
|
2016-06-13 14:05:23 +00:00
|
|
|
it 'does not expire' do
|
|
|
|
expect(build.reload.artifacts_expired?).to be_falsey
|
2016-06-10 15:27:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for expired artifacts' do
|
2016-06-13 16:18:24 +00:00
|
|
|
let!(:build) { create(:ci_build, artifacts_expire_at: Time.now - 7.days) }
|
2016-06-10 15:27:49 +00:00
|
|
|
|
2016-06-13 16:18:24 +00:00
|
|
|
it 'does not erase artifacts' do
|
|
|
|
expect_any_instance_of(Ci::Build).not_to have_received(:erase_artifacts!)
|
2016-06-10 15:27:49 +00:00
|
|
|
end
|
|
|
|
|
2016-06-13 16:18:24 +00:00
|
|
|
it 'does expire' do
|
2016-06-10 19:45:06 +00:00
|
|
|
expect(build.reload.artifacts_expired?).to be_truthy
|
2016-06-10 15:27:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|