Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests for rabbitmqctl version parsing #911

Merged
merged 1 commit into from
Aug 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"},'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note - I don't think the format has changed here between 3.1 and 3.7; just thought it was maybe a good idea to make the string a little more realistic (though it's still not multiline).

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