gitlab-org--gitlab-foss/spec/workers/expire_build_artifacts_work...

58 lines
1.4 KiB
Ruby
Raw Normal View History

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
2016-06-14 09:38:34 +00:00
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
2016-06-14 09:38:34 +00:00
it 'does remove files' do
expect(build.reload.artifacts_file.exists?).to be_falsey
end
2016-06-10 15:27:49 +00:00
end
context 'with not yet expired artifacts' do
2016-06-14 09:38:34 +00:00
let(:build) { create(:ci_build, :artifacts, artifacts_expire_at: Time.now + 7.days) }
2016-06-10 15:27:49 +00:00
2016-06-13 14:05:23 +00:00
it 'does not expire' do
2016-06-14 09:38:34 +00:00
expect(build.reload.artifacts_expired?).to be_falsey
end
it 'does not remove files' do
expect(build.reload.artifacts_file.exists?).to be_truthy
2016-06-10 15:27:49 +00:00
end
end
context 'without expire date' do
2016-06-14 09:38:34 +00:00
let(:build) { create(:ci_build, :artifacts) }
2016-06-10 15:27:49 +00:00
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
2016-06-14 09:38:34 +00:00
it 'does not remove files' do
expect(build.reload.artifacts_file.exists?).to be_truthy
end
2016-06-10 15:27:49 +00:00
end
context 'for expired artifacts' do
2016-06-14 09:38:34 +00:00
let(:build) { create(:ci_build, artifacts_expire_at: Time.now - 7.days) }
2016-06-10 15:27:49 +00:00
2016-06-14 09:38:34 +00:00
it 'is still expired' 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