X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fsystemd%2Fspec%2Funit%2Ffacter%2Fsystemd_version_spec.rb;fp=3rdparty%2Fmodules%2Fsystemd%2Fspec%2Funit%2Ffacter%2Fsystemd_version_spec.rb;h=5007dc69c873b98bf89b93285d83fc215184b63d;hb=1329adc9f34c3c87e353983ec9023a6cf6e93e67;hp=0000000000000000000000000000000000000000;hpb=a81ff959d6c9c7605db1176b89dc2b5ffde0d903;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/systemd/spec/unit/facter/systemd_version_spec.rb b/3rdparty/modules/systemd/spec/unit/facter/systemd_version_spec.rb new file mode 100644 index 000000000..5007dc69c --- /dev/null +++ b/3rdparty/modules/systemd/spec/unit/facter/systemd_version_spec.rb @@ -0,0 +1,31 @@ +require "spec_helper" + +describe Facter::Util::Fact do + before { + Facter.clear + } + + describe "systemd_version" do + context 'returns version when systemd fact present' do + before do + Facter.fact(:systemd).stubs(:value).returns(true) + end + let(:facts) { {:systemd => true} } + it do + Facter::Util::Resolution.expects(:exec).with("systemctl --version | awk '/systemd/{ print $2 }'").returns('229') + expect(Facter.value(:systemd_version)).to eq('229') + end + end + context 'returns nil when systemd fact not present' do + before do + Facter.fact(:systemd).stubs(:value).returns(false) + end + let(:facts) { {:systemd => false } } + it do + Facter::Util::Resolution.stubs(:exec) + Facter::Util::Resolution.expects(:exec).with("systemctl --version | awk '/systemd/{ print $2 }'").never + expect(Facter.value(:systemd_version)).to eq(nil) + end + end + end +end