| 1 |
# frozen_string_literal: true |
| 2 |
|
| 3 |
require 'spec_helper' |
| 4 |
|
| 5 |
describe Facter::Util::Fact do # rubocop:disable RSpec/FilePath |
| 6 |
before(:each) do |
| 7 |
Facter.clear |
| 8 |
end |
| 9 |
|
| 10 |
context 'when haproxy is present' do |
| 11 |
haproxy_version_output = <<-PUPPETCODE |
| 12 |
HA-Proxy version 1.5.3 2014/07/25 |
| 13 |
Copyright 2000-2014 Willy Tarreau <[email protected]> |
| 14 |
PUPPETCODE |
| 15 |
it do |
| 16 |
expect(Facter::Core::Execution).to receive(:which).at_least(1).with('haproxy').and_return(true) |
| 17 |
expect(Facter::Core::Execution).to receive(:execute).at_least(1).with('haproxy -v 2>&1').and_return(haproxy_version_output) |
| 18 |
expect(Facter.fact(:haproxy_version).value).to eq '1.5.3' |
| 19 |
end |
| 20 |
end |
| 21 |
|
| 22 |
context 'when haproxy is not present' do |
| 23 |
it do |
| 24 |
allow(Facter::Core::Execution).to receive(:execute) |
| 25 |
expect(Facter::Core::Execution).to receive(:which).at_least(1).with('haproxy').and_return(false) |
| 26 |
expect(Facter.fact(:haproxy_version)).to be_nil |
| 27 |
end |
| 28 |
end |
| 29 |
end |