diff --git a/spec/lib/abf-worker/build_lists_publish_task_manager_spec.rb b/spec/lib/abf-worker/build_lists_publish_task_manager_spec.rb index 1d702aa5a..7d5646aba 100644 --- a/spec/lib/abf-worker/build_lists_publish_task_manager_spec.rb +++ b/spec/lib/abf-worker/build_lists_publish_task_manager_spec.rb @@ -117,6 +117,67 @@ describe AbfWorker::BuildListsPublishTaskManager do end + describe 'creates not more than 4 tasks for publishing' do + before do + stub_redis + build_list.update_column(:status, BuildList::BUILD_PUBLISH) + 4.times { + bl = FactoryGirl.create(:build_list_core, :new_core => true) + bl.update_column(:status, BuildList::BUILD_PUBLISH) + } + 2.times{ subject.new.run } + end + + it "ensure that 'locked rep and platforms' has 4 items" do + @redis_instance.lrange(subject::LOCKED_REP_AND_PLATFORMS, 0, -1).should have(4).items + end + + it "ensure that 'locked build lists' has 4 items" do + @redis_instance.lrange(subject::LOCKED_BUILD_LISTS, 0, -1).should have(4).items + end + + it "ensure that new tasks for publishing has been created" do + @redis_instance.lrange('queue:publish_worker_default', 0, -1).should have(4).items + end + + end + + describe 'creates task for removing project from repository' do + before do + stub_redis + build_list.update_column(:status, BuildList::BUILD_PUBLISHED) + ProjectToRepository.where(:project_id => build_list.project_id, :repository_id => build_list.save_to_repository_id).destroy_all + 2.times{ subject.new.run } + end + + %w(RESIGN_REPOSITORIES + PROJECTS_FOR_CLEANUP + LOCKED_REPOSITORIES + LOCKED_BUILD_LISTS).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 projects for cleanup' has only one item" do + queue = @redis_instance.lrange(subject::LOCKED_PROJECTS_FOR_CLEANUP, 0, -1) + queue.should have(1).item + queue.should include("#{build_list.project_id}-#{build_list.save_to_repository_id}-#{build_list.build_for_platform_id}") + end + + it "ensure that new task for publishing has been created" do + @redis_instance.lrange('queue:publish_worker_default', 0, -1).should have(1).item + end + + end + describe 'resign packages in repository' do before do stub_redis