File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
lib/puppet/provider/logical_volume
spec/unit/puppet/provider/logical_volume Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ def destroy
157157 end
158158
159159 def exists?
160- lvs ( @resource [ :volume_group ] ) =~ %r{ #{ @resource [ :name ] } }
160+ lvs ( @resource [ :volume_group ] ) =~ lvs_pattern
161161 rescue Puppet ::ExecutionFailure
162162 # lvs fails if we give it an empty volume group name, as would
163163 # happen if we were running `puppet resource`. This should be
Original file line number Diff line number Diff line change 99 end
1010
1111 lvs_output = <<-EOS
12- LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
13- lv_root VolGroup -wi-ao---- 18.54g
14- lv_swap VolGroup -wi-ao---- 992.00m
15- data data -wi-ao---- 992.00m
12+ LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
13+ lv_root VolGroup -wi-ao---- 18.54g
14+ lv_swap VolGroup -wi-ao---- 992.00m
15+ data data -wi-ao---- 992.00m
16+ j1 vg_jenkins -wi-a----- 1.00g
1617 EOS
1718
1819 describe 'self.instances' do
3435 @provider . class . stubs ( :lvs ) . with ( 'data' ) . returns ( lvs_output )
3536 expect ( @provider . exists? ) . to be > 10
3637 end
38+ it "returns 'nil', lv 'jenkins' in vg 'vg_jenkins' exists" do
39+ @resource . expects ( :[] ) . with ( :name ) . returns ( 'jenkins' )
40+ @resource . expects ( :[] ) . with ( :volume_group ) . returns ( 'vg_jenkins' ) . at_least_once
41+ @provider . class . stubs ( :lvs ) . with ( 'vg_jenkins' ) . returns ( lvs_output )
42+ expect ( @provider . exists? ) . to be_nil
43+ end
3744 it "returns 'nil', lv 'data' in vg 'myvg' does not exist" do
3845 @resource . expects ( :[] ) . with ( :volume_group ) . returns ( 'myvg' ) . at_least_once
3946 @provider . class . stubs ( :lvs ) . with ( 'myvg' ) . raises ( Puppet ::ExecutionFailure , 'Execution of \'/sbin/lvs myvg\' returned 5' )
You can’t perform that action at this time.
0 commit comments