#794: add new specs for BuildListsPublishTaskManager

This commit is contained in:
Vokhmin Alexey V 2013-01-18 18:28:31 +04:00
parent f08b5d3aa7
commit cc8ffb26e8
3 changed files with 32 additions and 1 deletions

View File

@ -162,7 +162,6 @@ module AbfWorker
bl bl
end.compact end.compact
bl = build_lists.first || build_lists_for_cleanup.first bl = build_lists.first || build_lists_for_cleanup.first
return false unless bl return false unless bl

View File

@ -6,6 +6,8 @@ describe AbfWorker::BuildListsPublishTaskManager do
end end
subject { AbfWorker::BuildListsPublishTaskManager } subject { AbfWorker::BuildListsPublishTaskManager }
let(:build_list) { FactoryGirl.create(:build_list_core, :new_core => true) }
let(:build_list2) { FactoryGirl.create(:build_list_core, :new_core => true) }
describe 'when no items for publishing' do describe 'when no items for publishing' do
before do before do
@ -33,6 +35,35 @@ describe AbfWorker::BuildListsPublishTaskManager do
end end
describe 'when one build_list for publishing' do
before do
build_list.update_column(:status, BuildList::BUILD_PUBLISH)
stub_redis
2.times{ subject.new.run }
end
%w(RESIGN_REPOSITORIES
PROJECTS_FOR_CLEANUP
LOCKED_PROJECTS_FOR_CLEANUP
LOCKED_REPOSITORIES).each do |kind|
it "ensure that no '#{kind.downcase.gsub('_', ' ')}'" do
@redis_instance.lrange(subject.const_get(kind), 0, -1).should be_empty
end
end
it "ensure that 'locked rep and platforms' has only one item" do
queue = @redis_instance.lrange(subject::LOCKED_REP_AND_PLATFORMS, 0, -1)
queue.should have(1).item
queue.should include("#{build_list.save_to_repository_id}-#{build_list.build_for_platform_id}")
end
it "ensure that 'locked build lists' has only one item" do
queue = @redis_instance.lrange(subject::LOCKED_BUILD_LISTS, 0, -1)
queue.should have(1).item
queue.should include(build_list.id.to_s)
end
end
after(:all) do after(:all) do

View File

@ -62,6 +62,7 @@ end
def stub_redis def stub_redis
@redis_instance = MockRedis.new @redis_instance = MockRedis.new
stub(Redis).new { @redis_instance } stub(Redis).new { @redis_instance }
stub(Resque).redis { @redis_instance }
end end
init_test_root init_test_root