Sha256: e21ff88fe876fd14e3c3381c14bd3fc7534fdf97e7c663ff1fbe3498d16c3afc

Contents?: true

Size: 1.83 KB

Versions: 18

Compression:

Stored size: 1.83 KB

Contents

require 'rails_helper'

module Kuroko2::Workflow::Task
  describe Queue do
    describe '#execute' do
      subject { token.context['QUEUE'] }

      let(:token) { build(:token, script: 'queue:') }
      let(:queue) { Kuroko2::Execution::DEFAULT_QUEUE }

      before do
        Kuroko2::Worker.create!(hostname: 'test', worker_id: 1, queue: queue, working: true)
      end

      context 'valid case' do
        before { Kuroko2::Workflow::Task::Queue.new(node, token).execute }

        context 'with default queue' do
          let(:node) { Kuroko2::Workflow::Node.new(:queue) }

          it { is_expected.to eq queue }
        end

        context 'with given queue' do
          let(:queue) { 'queue_name' }
          let(:node) { Kuroko2::Workflow::Node.new(:queue, queue) }

          it { is_expected.to eq queue }
        end
      end

      context 'with default queue' do
        let(:node) { Kuroko2::Workflow::Node.new(:queue, '@default') }
        it { expect { Kuroko2::Workflow::Task::Queue.new(node, token).validate }.not_to raise_error }
      end

      context 'with valid queue' do
        before { create(:worker, queue: 'myqueue') }
        let(:node) { Kuroko2::Workflow::Node.new(:queue, 'myqueue') }
        it { expect { Kuroko2::Workflow::Task::Queue.new(node, token).validate }.not_to raise_error }
      end

      context 'with invalid queue' do
        let(:node) { Kuroko2::Workflow::Node.new(:queue, '!invalid!') }

        it { expect { Kuroko2::Workflow::Task::Queue.new(node, token).validate }.to raise_error(Kuroko2::Workflow::AssertionError) }
      end

      context 'with no existance queue' do
        let(:node) { Kuroko2::Workflow::Node.new(:queue, 'invalid') }

        it { expect { Kuroko2::Workflow::Task::Queue.new(node, token).validate }.to raise_error(Kuroko2::Workflow::AssertionError) }
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
kuroko2-0.8.0 spec/workflow/task/queue_spec.rb
kuroko2-0.7.0 spec/workflow/task/queue_spec.rb
kuroko2-0.6.0 spec/workflow/task/queue_spec.rb
kuroko2-0.5.2 spec/workflow/task/queue_spec.rb
kuroko2-0.5.1 spec/workflow/task/queue_spec.rb
kuroko2-0.5.0 spec/workflow/task/queue_spec.rb
kuroko2-0.4.6 spec/workflow/task/queue_spec.rb
kuroko2-0.4.5 spec/workflow/task/queue_spec.rb
kuroko2-0.4.4 spec/workflow/task/queue_spec.rb
kuroko2-0.4.3 spec/workflow/task/queue_spec.rb
kuroko2-0.4.2 spec/workflow/task/queue_spec.rb
kuroko2-0.4.1 spec/workflow/task/queue_spec.rb
kuroko2-0.4.0 spec/workflow/task/queue_spec.rb
kuroko2-0.3.4 spec/workflow/task/queue_spec.rb
kuroko2-0.3.3 spec/workflow/task/queue_spec.rb
kuroko2-0.3.2 spec/workflow/task/queue_spec.rb
kuroko2-0.3.1 spec/workflow/task/queue_spec.rb
kuroko2-0.3.0 spec/workflow/task/queue_spec.rb