Skip to content

Commit 7d8052b

Browse files
committed
fix tests
1 parent d2454c9 commit 7d8052b

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

lib/facter/lvm_support.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
Facter.add('lvm_vgs') do
1818
confine lvm_support: true
1919

20-
if Facter.value(:lvm_support)
21-
vgs = Facter::Core::Execution.execute('vgs -o name --noheadings 2>/dev/null', timeout: 30)
22-
end
20+
vgs = Facter::Core::Execution.execute('vgs -o name --noheadings 2>/dev/null', timeout: 30)
2321

2422
if vgs.nil?
2523
setcode { 0 }
@@ -50,10 +48,8 @@
5048
pv_list = []
5149
Facter.add('lvm_pvs') do
5250
confine lvm_support: true
53-
if Facter.value(:lvm_support)
54-
pvs = Facter::Core::Execution.execute('pvs -o name --noheadings 2>/dev/null', timeout: 30)
55-
end
5651

52+
pvs = Facter::Core::Execution.execute('pvs -o name --noheadings 2>/dev/null', timeout: 30)
5753
if pvs.nil?
5854
setcode { 0 }
5955
else

spec/unit/facter/lvm_support_spec.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
context 'when there is lvm support' do
5555
context 'when there are no vgs' do
5656
it 'is set to 0' do
57-
allow(Facter::Core::Execution).to receive(:execute) # All other calls
57+
Facter::Core::Execution.stubs(:execute) # All other calls
5858
Facter::Core::Execution.expects(:execute).at_least(1).with('vgs -o name --noheadings 2>/dev/null', timeout: 30).returns(nil)
5959
Facter.fact(:lvm_support).expects(:value).at_least(1).returns(true)
6060
Facter.value(:lvm_vgs).should == 0
@@ -64,7 +64,7 @@
6464
context 'when there are vgs' do
6565
it 'lists vgs' do
6666
Facter::Core::Execution.stubs(:execute) # All other calls
67-
Facter::Core::Execution.expects(:execute).at_least(1).with('vgs -o name --noheadings 2>/dev/null', timeout: 30).returns("vg0\nvg1")
67+
Facter::Core::Execution.expects(:execute).at_least(1).with('vgs -o name --noheadings 2>/dev/null', timeout: 30).returns(" vg0\n vg1")
6868
Facter::Core::Execution.expects(:execute).at_least(1).with('vgs -o pv_name vg0 2>/dev/null', timeout: 30).returns(" PV\n /dev/pv3\n /dev/pv2")
6969
Facter::Core::Execution.expects(:execute).at_least(1).with('vgs -o pv_name vg1 2>/dev/null', timeout: 30).returns(" PV\n /dev/pv0")
7070
Facter.fact(:lvm_support).expects(:value).at_least(1).returns(true)
@@ -86,7 +86,6 @@
8686

8787
context 'when there is no lvm support' do
8888
it 'does not exist' do
89-
Facter.fact(:lvm_support).expects(:value).at_least(1).returns(nil)
9089
Facter.value(:lvm_pvs).should be_nil
9190
end
9291
end
@@ -104,7 +103,7 @@
104103
context 'when there are pvs' do
105104
it 'lists pvs' do
106105
Facter::Core::Execution.stubs('execute') # All other calls
107-
Facter::Core::Execution.expects('execute').at_least(1).with('pvs -o name --noheadings 2>/dev/null', timeout: 30).returns("pv0\npv1")
106+
Facter::Core::Execution.expects('execute').at_least(1).with('pvs -o name --noheadings 2>/dev/null', timeout: 30).returns(" pv0\n pv1")
108107
Facter.fact(:lvm_support).expects(:value).at_least(1).returns(true)
109108
Facter.value(:lvm_pvs).should == 2
110109
Facter.value(:lvm_pv_0).should == 'pv0'

0 commit comments

Comments
 (0)