Merge pull request #1 from soapy1/rmi-test

Test rmi functionality for docker provider
This commit is contained in:
Terry Burton 2020-03-23 23:24:12 +00:00 committed by GitHub
commit d372ba0b5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -379,6 +379,44 @@ describe VagrantPlugins::DockerProvider::Driver do
end
end
describe '#rmi' do
let(:id) { 'asdg21ew' }
context 'image exists' do
it "removes the image" do
expect(subject).to receive(:execute).with('docker', 'rmi', id)
subject.rmi(id)
end
end
context 'image is being used' do
before { allow(subject).to receive(:execute).and_raise("image is being used by running container") }
it 'does not remove the image' do
expect(subject.rmi(id)).to eq(false)
subject.rmi(id)
end
end
context 'container is using it' do
before { allow(subject).to receive(:execute).and_raise("container is using it") }
it 'does not remove the image' do
expect(subject.rmi(id)).to eq(false)
subject.rmi(id)
end
end
context 'image does not exist' do
before { allow(subject).to receive(:execute).and_raise("No such image") }
it 'raises an error' do
expect(subject.rmi(id)).to eq(nil)
subject.rmi(id)
end
end
end
describe '#inspect_container' do
let(:data) { '[{"json": "value"}]' }