Sha256: ff9c1af4472e85e4f4b9839a7260971df19fcd6da8a8e23de03b98d0ee3245f5

Contents?: true

Size: 1.58 KB

Versions: 6

Compression:

Stored size: 1.58 KB

Contents

require 'minitest_helper'

describe Asynchronic, 'Facade' do

  before do
    Asynchronic.environment.data_store.clear
    Asynchronic.environment.queue_engine.clear
  end
  
  it 'Default queue' do
    Asynchronic.default_queue.must_equal :asynchronic
  end

  it 'Default queue_engine' do
    Asynchronic.queue_engine.must_be_instance_of Asynchronic::QueueEngine::InMemory
  end

  it 'Default data store' do
    Asynchronic.data_store.must_be_instance_of Asynchronic::DataStore::InMemory
  end

  it 'Default logger' do
    Asynchronic.logger.must_be_instance_of Logger
  end

  it 'Environment' do
    Asynchronic.environment.tap do |env|
      env.queue_engine.must_equal Asynchronic.queue_engine
      env.data_store.connection.must_equal Asynchronic.data_store.scoped(:asynchronic).connection
    end
  end

  it 'Load process' do
    process = Asynchronic.environment.create_process BasicJob
    Asynchronic[process.id].tap do |p|
      p.id.must_equal process.id
      p.type.must_equal process.type
      p.created_at.must_equal process.created_at
    end
  end

  it 'List processes' do
    ids = 3.times.map do 
      process = Asynchronic.environment.create_process SequentialJob
      process.id
    end

    Asynchronic.processes.count.must_equal 3
    3.times { |i| Asynchronic.processes[i].id == ids[i] }
  end

  it 'Enqueue' do
    id = BasicJob.enqueue input: 100
    
    Asynchronic.environment.tap do |env|
      process = env.load_process id
      process.type.must_equal BasicJob
      process.params[:input].must_equal 100
      env.default_queue.must_enqueued process
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
asynchronic-0.3.1 spec/facade_spec.rb
asynchronic-0.3.0 spec/facade_spec.rb
asynchronic-0.2.3 spec/facade_spec.rb
asynchronic-0.2.2 spec/facade_spec.rb
asynchronic-0.2.1 spec/facade_spec.rb
asynchronic-0.2.0 spec/facade_spec.rb