Skip to content

Commit

Permalink
Update tests for rabbitmqctl version parsing
Browse files Browse the repository at this point in the history
- Update existing tests to include the leading spaces and some
  additional formatting
- Add new test case for the newer format included in `rabbitmqctl -q
  status` that's included in RabbitMQ >= v3.8.x, originally fixed in
  #814

See discussion in #872
  • Loading branch information
wyardley committed Jul 31, 2022
1 parent 1e8c72e commit d8e1013
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions spec/unit/puppet/provider/rabbitmq_cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@
end

it 'gets the RabbitMQ version' do
provider_class.expects(:rabbitmqctl).with('-q', 'status').returns '{rabbit,"RabbitMQ","3.1.5"}'
expect(provider_class.rabbitmq_version).to eq('3.1.5')
provider_class.expects(:rabbitmqctl).with('-q', 'status').returns ' [{rabbit,"RabbitMQ","3.7.28"},'
expect(provider_class.rabbitmq_version).to eq('3.7.28')
end

it 'caches the RabbitMQ version' do
provider_class.expects(:rabbitmqctl).with('-q', 'status').returns '{rabbit,"RabbitMQ","3.7.10"}'
provider_class.expects(:rabbitmqctl).with('-q', 'status').returns ' [{rabbit,"RabbitMQ","3.7.28"},'
v1 = provider_class.rabbitmq_version

# No second expects for rabbitmqctl as it shouldn't be called again
expect(provider_class.rabbitmq_version).to eq(v1)
end

it 'gets the RabbitMQ version with version >= 3.8' do
provider_class.expects(:rabbitmqctl).with('-q', 'status').returns 'RabbitMQ version: 3.10.6'
expect(provider_class.rabbitmq_version).to eq('3.10.6')
end

it 'uses correct list options with RabbitMQ < 3.7.9' do
provider_class.expects(:rabbitmq_version).returns '3.7.8'
provider_class.expects(:rabbitmqctl).with('list_vhost', '-q').returns ''
Expand Down

0 comments on commit d8e1013

Please sign in to comment.