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
157
157
end
158
158
159
159
def exists?
160
- lvs ( @resource [ :volume_group ] ) =~ %r{ #{ @resource [ :name ] } }
160
+ lvs ( @resource [ :volume_group ] ) =~ lvs_pattern
161
161
rescue Puppet ::ExecutionFailure
162
162
# lvs fails if we give it an empty volume group name, as would
163
163
# happen if we were running `puppet resource`. This should be
Original file line number Diff line number Diff line change 9
9
end
10
10
11
11
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
16
17
EOS
17
18
18
19
describe 'self.instances' do
34
35
@provider . class . stubs ( :lvs ) . with ( 'data' ) . returns ( lvs_output )
35
36
expect ( @provider . exists? ) . to be > 10
36
37
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
37
44
it "returns 'nil', lv 'data' in vg 'myvg' does not exist" do
38
45
@resource . expects ( :[] ) . with ( :volume_group ) . returns ( 'myvg' ) . at_least_once
39
46
@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