From cc8ffb26e89f6b37d49d63c0bfebc94ede7fc6a1 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 18 Jan 2013 18:28:31 +0400 Subject: [PATCH] #794: add new specs for BuildListsPublishTaskManager --- .../build_lists_publish_task_manager.rb | 1 - .../build_lists_publish_task_manager_spec.rb | 31 +++++++++++++++++++ spec/spec_helper.rb | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index 6e10cbda6..22d22cc82 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -162,7 +162,6 @@ module AbfWorker bl end.compact - bl = build_lists.first || build_lists_for_cleanup.first return false unless bl 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 5a8c71451..0ebb1aa50 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 @@ -6,6 +6,8 @@ describe AbfWorker::BuildListsPublishTaskManager do end 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 before do @@ -33,6 +35,35 @@ describe AbfWorker::BuildListsPublishTaskManager do 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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9d77f115a..139e9abd0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -62,6 +62,7 @@ end def stub_redis @redis_instance = MockRedis.new stub(Redis).new { @redis_instance } + stub(Resque).redis { @redis_instance } end init_test_root