X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Frabbitmq%2Fspec%2Funit%2Ffacter%2Futil%2Ffact_rabbitmq_version_spec.rb;fp=3rdparty%2Fmodules%2Frabbitmq%2Fspec%2Funit%2Ffacter%2Futil%2Ffact_rabbitmq_version_spec.rb;h=b4c4420da94ba25c0dec856515b4cdf5d757c44b;hb=921e69100a563cf143f56a3905d8362336d939ff;hp=0000000000000000000000000000000000000000;hpb=b54f52d2899c5785923c804fdfbba0782c147da4;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/rabbitmq/spec/unit/facter/util/fact_rabbitmq_version_spec.rb b/3rdparty/modules/rabbitmq/spec/unit/facter/util/fact_rabbitmq_version_spec.rb new file mode 100644 index 000000000..b4c4420da --- /dev/null +++ b/3rdparty/modules/rabbitmq/spec/unit/facter/util/fact_rabbitmq_version_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe Facter::Util::Fact do + before do + Facter.clear + end + + describe 'rabbitmq_version' do + context 'with value' do + before do + allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { true } + allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqadmin --version 2>&1') { 'rabbitmqadmin 3.6.0' } + end + it do + expect(Facter.fact(:rabbitmq_version).value).to eq('3.6.0') + end + end + context 'with invalid value' do + before do + allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { true } + allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqadmin --version 2>&1') { 'rabbitmqadmin %%VSN%%' } + end + it do + expect(Facter.fact(:rabbitmq_version).value).to be_nil + end + end + context 'rabbitmqadmin is not in path' do + before do + allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { false } + end + it do + expect(Facter.fact(:rabbitmq_version).value).to be_nil + end + end + end +end