Skip to content

Commit d3a8cb9

Browse files
committed
added tests
1 parent c767de3 commit d3a8cb9

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

spec/unit/puppet/provider/logical_volume/lvm_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@
134134
@provider.create
135135
end
136136
end
137+
context 'with named thinpool option' do
138+
it "should execute 'lvcreate' with '--virtualsize 1g' and '--thin myvg/mythinpool' options" do
139+
@resource.expects(:[]).with(:name).returns('mylv')
140+
@resource.expects(:[]).with(:volume_group).returns('myvg')
141+
@resource.expects(:[]).with(:size).returns('1g').at_least_once
142+
@resource.expects(:[]).with(:thinpool).returns('mythinpool').at_least_once
143+
@provider.expects(:lvcreate).with('-n', 'mylv', '--virtualsize', '1g', '--thin', 'myvg/mythinpool')
144+
@provider.create
145+
end
146+
end
137147
end
138148

139149
describe "when modifying" do
@@ -189,6 +199,20 @@
189199
expect { @provider.size = '1100000k' }.not_to raise_error(Puppet::ExecutionFailure, /blkid/)
190200
end
191201
end
202+
context "with defined thin pool" do
203+
it "should execute 'lvextend' as with normal volume" do
204+
@resource.expects(:[]).with(:name).returns('mylv').at_least_once
205+
@resource.expects(:[]).with(:volume_group).returns('myvg').at_least_once
206+
@resource.expects(:[]).with(:size).returns('1g').at_least_once
207+
@resource.expects(:[]).with(:thinpool).returns('mythinpool').at_least_once
208+
@provider.expects(:lvcreate).with('-n', 'mylv', '--virtualsize', '1g', '--thin', 'myvg/mythinpool')
209+
@provider.create
210+
@provider.expects(:lvs).with('--noheading', '--unit', 'g', '/dev/myvg/mylv').returns(' 1.00g').at_least_once
211+
@provider.expects(:lvs).with('--noheading', '-o', 'vg_extent_size', '--units', 'k', '/dev/myvg/mylv').returns(' 1000.00k')
212+
@provider.expects(:lvextend).with('-L', '2000000k', '/dev/myvg/mylv').returns(true)
213+
@provider.size = '2000000k'
214+
end
215+
end
192216
end
193217
context "not in extent portions" do
194218
it "should raise an exception" do

spec/unit/puppet/type/logical_volume_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110
resource[:thinpool].should == false
111111
end
112112
end
113+
it "should support 'thinpool name' as a value" do
114+
with(valid_params.merge(:thinpool => 'mythinpool')) do |resource|
115+
resource[:thinpool].should == 'mythinpool'
116+
end
117+
end
113118
it "should not support other values" do
114119
specifying(valid_params.merge(:thinpool => :moep)).should raise_error(Puppet::Error)
115120
end

0 commit comments

Comments
 (0)