Skip to content

Commit

Permalink
fix tests depending on docker command existing
Browse files Browse the repository at this point in the history
  • Loading branch information
h0tw1r3 committed Aug 4, 2024
1 parent 0fe9ed5 commit 1788772
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions spec/lib/vanagon/engine/docker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
require 'vanagon/platform'

describe Vanagon::Engine::Docker do
before(:each) do
allow(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_return('/usr/bin/docker')
end

let (:platform_with_docker_image) do
plat = Vanagon::Platform::DSL.new('debian-10-amd64')
plat.instance_eval(<<~EOF)
Expand Down Expand Up @@ -34,6 +38,7 @@

describe '#initialize' do
it 'fails without docker installed' do
allow(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_call_original
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path_elem|
expect(FileTest).to receive(:executable?).with(File.join(path_elem, 'docker')).and_return(false)
end
Expand All @@ -44,18 +49,15 @@

describe "#validate_platform" do
it 'raises an error if the platform is missing a required attribute' do
expect(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_return('/usr/bin/docker')
expect { described_class.new(platform_without_docker_image).validate_platform }.to raise_error(Vanagon::Error)
end

it 'returns true if the platform has the required attributes' do
expect(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_return('/usr/bin/docker')
expect(described_class.new(platform_with_docker_image).validate_platform).to be(true)
end
end

it 'returns "docker" name' do
expect(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_return('/usr/bin/docker')
expect(described_class.new(platform_with_docker_image).name).to eq('docker')
end

Expand Down

0 comments on commit 1788772

Please sign in to comment.