File: queue_redeclaration_with_incompatible_attributes_spec.rb

package info (click to toggle)
ruby-amqp 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,508 kB
  • sloc: ruby: 8,272; sh: 11; makefile: 10
file content (72 lines) | stat: -rw-r--r-- 1,883 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# encoding: utf-8

require 'spec_helper'

describe "AMQP queue redeclaration with different attributes" do

  #
  # Environment
  #

  include EventedSpec::AMQPSpec

  default_timeout 5


  #
  # Examples
  #

  context "when :durable value is different" do
    let(:name)              { "amqp-gem.nondurable.queue" }
    let(:options)           {
      { :durable => false, :exclusive => true, :auto_delete => true, :arguments => {}, :passive => false }
    }
    let(:different_options) {
      { :durable => true, :exclusive => true, :auto_delete => true, :arguments => {}, :passive => false}
    }


    it "should raise AMQP::IncompatibleOptionsError for incompatable options" do
      channel = AMQP::Channel.new
      channel.on_error do |ch, channel_close|
        @error_code = channel_close.reply_code
      end

      channel.queue(name, options)
      expect {
        channel.queue(name, different_options)
      }.to raise_error

      done(0.5) {
        @error_code.should == 406
      }
    end
  end

  context "when :headers are different" do
    let(:name)              { "amqp-gem.nondurable.queue" }
    let(:options)           {
      { :durable => false, :exclusive => true, :auto_delete => true, :arguments => {}, :passive => false }
    }
    let(:different_options) {
      { :durable => false, :exclusive => true, :auto_delete => true, :arguments => {}, :passive => false, :header => {:random => 'stuff' } }
    }

    it "should not raise AMQP::IncompatibleOptionsError for irrelevant options" do
      channel = AMQP::Channel.new
      channel.on_error do |ch, channel_close|
        @error_code = channel_close.reply_code
      end

      channel.queue(name, options)
      expect {
        channel.queue(name, different_options)
      }.to_not raise_error

      done(0.5) {
        @error_code.should == 406
      }
    end
  end
end # describe AMQP