|
133 | 133 | end
|
134 | 134 | end
|
135 | 135 |
|
136 |
| - context 'copy image' do |
| 136 | + context 'image actions' do |
137 | 137 | before :all do
|
138 | 138 | @qcow2_path = File.join(@tmpdir, 'base.qcow2')
|
139 | 139 | @raw_path = File.join(@tmpdir, 'base.raw')
|
140 |
| - # # 200 Mb |
141 |
| - # Cangallo::Qcow2.create(@qcow2_path, File.join(@tmpdir, 'base.qcow2'), 2 * IMAGE_SIZE) |
142 |
| - # Cangallo::Qcow2.create(@raw_path, File.join(@tmpdir, 'base.raw'), 2 * IMAGE_SIZE) |
| 140 | + @parent_path = File.join(@tmpdir, 'child_qcow2.qcow2') |
143 | 141 | end
|
144 | 142 |
|
145 | 143 | it 'should be able to create it' do
|
|
182 | 180 | expect(File.basename(info['backing-filename'])).to eq('base.raw')
|
183 | 181 | expect(File.basename(info['backing-filename-format'])).to eq('raw')
|
184 | 182 | end
|
| 183 | + |
| 184 | + it 'should be able to sparsify it (qcow2)' do |
| 185 | + path = File.join(@tmpdir, 'sparsify.qcow2') |
| 186 | + q = Cangallo::Qcow2.new(@parent_path) |
| 187 | + q.sparsify(path) |
| 188 | + |
| 189 | + expect(File).to exist(path) |
| 190 | + |
| 191 | + info = Cangallo::Qcow2.new(path).info |
| 192 | + expect(info).not_to eq(nil) |
| 193 | + |
| 194 | + expect(info['virtual-size']).to eq(2 * IMAGE_SIZE) |
| 195 | + expect(info['cluster-size']).to eq(65_536) |
| 196 | + expect(info['format']).to eq('qcow2') |
| 197 | + expect(info['actual-size']).to eq(200_704) |
| 198 | + expect(info['backing-filename']).to eq(nil) |
| 199 | + expect(info['backing-filename-format']).to eq(nil) |
| 200 | + end |
185 | 201 | end
|
186 | 202 | end
|
0 commit comments