Sha256: 9482e5a3fdc978c8b08b86abf54f196abe9dda38eb4c5b401a08d1768a7a807b

Contents?: true

Size: 1005 Bytes

Versions: 1

Compression:

Stored size: 1005 Bytes

Contents

require_relative 'test_helper'
require_relative 'jobs/test_job'

# Unit Test for RocketJob::Server
class ServerTest < Minitest::Test
  context RocketJob::Server do
    setup do
      RocketJob::Config.instance.heartbeat_seconds = 0.1
      RocketJob::Config.instance.max_poll_seconds  = 0.1
      @server = RocketJob::Server.new
      @description = 'Hello World'
      @arguments   = [ 1 ]
      @job = Jobs::TestJob.new(
        description:         @description,
        arguments:           @arguments,
        destroy_on_complete: false
      )
    end

    teardown do
      @job.destroy if @job && !@job.new_record?
    end

    context '.config' do
      should 'support multiple databases' do
        assert_equal 'test_rocket_job', RocketJob::Job.collection.db.name
      end
    end

    context '#run' do
      should 'run a server' do
        Thread.new { sleep 1; @server.stop!}
        @server.run
        assert_equal :stopping, @server.state, @server.inspect
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rocketjob-0.7.0 test/server_test.rb