Sha256: 848a3db6f9059217fb25a0a616d07a8980e7bb5cc6d2ac06fdb5f4aa15e51ad5

Contents?: true

Size: 756 Bytes

Versions: 2

Compression:

Stored size: 756 Bytes

Contents

# encoding: utf-8
require 'logstash/outputs/gcs/worker_pool'

describe LogStash::Outputs::Gcs::WorkerPool do
  describe '#post' do
    it 'runs the task in the same thread if synchronous' do
      pool = LogStash::Outputs::Gcs::WorkerPool.new(5, true)
      expect(pool.workers).to_not receive(:post)

      pool.post { 1 + 2 }
    end

    it 'runs the task in a different thread if asynchronous' do
      pool = LogStash::Outputs::Gcs::WorkerPool.new(5, false)
      expect(pool.workers).to receive(:post)

      pool.post { 1 + 2 }
    end

    it 'raises an error if the pool is already stopped' do
      pool = LogStash::Outputs::Gcs::WorkerPool.new(5, true)
      pool.stop!

      expect{ pool.post{} }.to raise_error(RuntimeError)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logstash-output-google_cloud_storage-3.2.1 spec/outputs/gcs/worker_pool_spec.rb
logstash-output-google_cloud_storage-3.2.0 spec/outputs/gcs/worker_pool_spec.rb