File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
lib/puppet/provider/logical_volume
spec/unit/puppet/provider/logical_volume Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -293,7 +293,9 @@ def mirrorlog=( new_mirror_log_location )
293293 private
294294
295295 def lvs_pattern
296- /\s +#{ Regexp . quote @resource [ :name ] } \s +/
296+ # lvs output format:
297+ # LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
298+ /\s +#{ Regexp . quote @resource [ :name ] } \s +#{ Regexp . quote @resource [ :volume_group ] } \s +/
297299 end
298300
299301 def path
Original file line number Diff line number Diff line change 1313 LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
1414 lv_root VolGroup -wi-ao---- 18.54g
1515 lv_swap VolGroup -wi-ao---- 992.00m
16+ data data -wi-ao---- 992.00m
1617 EOS
1718
1819 describe 'self.instances' do
2728 end
2829 end
2930
31+ describe 'when checking existence' do
32+ it "should return 'true', lv 'data' in vg 'data' exists" do
33+ @resource . expects ( :[] ) . with ( :name ) . returns ( 'data' )
34+ @resource . expects ( :[] ) . with ( :volume_group ) . returns ( 'data' ) . at_least_once
35+ @provider . class . stubs ( :lvs ) . with ( 'data' ) . returns ( lvs_output )
36+ expect ( @provider . exists? ) . to be > 10
37+ end
38+ it "should return 'nil', lv 'data' in vg 'myvg' does not exist" do
39+ @resource . expects ( :[] ) . with ( :name ) . returns ( 'data' )
40+ @resource . expects ( :[] ) . with ( :volume_group ) . returns ( 'myvg' ) . at_least_once
41+ @provider . class . stubs ( :lvs ) . with ( 'myvg' ) . returns ( lvs_output )
42+ expect ( @provider . exists? ) . to be_nil
43+ end
44+ end
45+
3046 describe 'when inspecting' do
3147 it "strips zeros from lvs output" do
3248 @resource . expects ( :[] ) . with ( :name ) . returns ( 'mylv' ) . at_least_once
You can’t perform that action at this time.
0 commit comments