Skip to content

Commit

Permalink
fix tests after Beaker::Platform refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Sep 20, 2024
1 parent 36bf47f commit 4769add
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions spec/beaker/hypervisor/docker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
require 'fakefs/spec_helpers'

module Beaker
platforms = [
platform_names = [
'ubuntu-14.04-x86_64',
'cumulus-2.2-x86_64',
'fedora-22-x86_64',
'centos-7-x86_64',
'sles-12-x86_64',
'archlinux-2017.12.27-x86_64',
'amazon-2023-x86_64',
]
platforms = platform_names.map { |name| Beaker::Platform.new(name) }

describe Docker do
require 'docker'
Expand Down Expand Up @@ -190,13 +190,13 @@ module Beaker
end

it 'accepts alpine as valid platform' do
host['platform'] = 'alpine-3.8-x86_64'
host['platform'] = Beaker::Platform.new('alpine-3.8-x86_64')
expect(test_container).to receive(:exec).at_least(:twice)
docker.install_ssh_components(test_container, host)
end

it 'raises an error with an unsupported platform' do
host['platform'] = 'boogeyman-2000-x86_64'
host['platform'] = Beaker::Platform.new('boogeyman-2000-x86_64')
expect { docker.install_ssh_components(test_container, host) }.to raise_error(RuntimeError, /boogeyman/)
end
end
Expand Down Expand Up @@ -632,7 +632,7 @@ module Beaker
describe '#dockerfile_for' do
FakeFS.deactivate!
it 'raises on an unsupported platform' do
expect { docker.send(:dockerfile_for, { 'platform' => 'a_sidewalk', 'image' => 'foobar' }) }.to raise_error(/platform a_sidewalk not yet supported/)
expect { docker.send(:dockerfile_for, { 'platform' => Beaker::Platform.new('a_sidewalk'), 'image' => 'foobar' }) }.to raise_error(/platform a_sidewalk not yet supported/)
end

it 'sets "ENV container docker"' do
Expand Down Expand Up @@ -696,7 +696,7 @@ module Beaker
it 'uses zypper on sles' do
FakeFS.deactivate!
dockerfile = docker.send(:dockerfile_for, {
'platform' => 'sles-12-x86_64',
'platform' => Beaker::Platform.new('sles-12-x86_64'),
'image' => 'foobar',
})

Expand All @@ -707,7 +707,7 @@ module Beaker
it "uses dnf on fedora #{fedora_release}" do
FakeFS.deactivate!
dockerfile = docker.send(:dockerfile_for, {
'platform' => "fedora-#{fedora_release}-x86_64",
'platform' => Beaker::Platform.new("fedora-#{fedora_release}-x86_64"),
'image' => 'foobar',
})

Expand All @@ -718,7 +718,7 @@ module Beaker
it 'uses pacman on archlinux' do
FakeFS.deactivate!
dockerfile = docker.send(:dockerfile_for, {
'platform' => 'archlinux-current-x86_64',
'platform' => Beaker::Platform.new('archlinux-current-x86_64'),
'image' => 'foobar',
})

Expand Down Expand Up @@ -747,21 +747,21 @@ module Beaker
end

it 'execs sshd on alpine' do
host['platform'] = 'alpine-3.8-x86_64'
host['platform'] = Beaker::Platform.new('alpine-3.8-x86_64')
expect(test_container).to receive(:exec).with(array_including('sed'))
expect(test_container).to receive(:exec).with(%w[/usr/sbin/sshd])
docker.send(:fix_ssh, test_container, host)
end

it 'restarts ssh service on ubuntu' do
host['platform'] = 'ubuntu-20.04-x86_64'
host['platform'] = Beaker::Platform.new('ubuntu-20.04-x86_64')
expect(test_container).to receive(:exec).with(array_including('sed'))
expect(test_container).to receive(:exec).with(%w[service ssh restart])
docker.send(:fix_ssh, test_container, host)
end

it 'restarts sshd service otherwise' do
host['platform'] = 'boogeyman-2000-x86_64'
host['platform'] = Beaker::Platform.new('boogeyman-2000-x86_64')
expect(test_container).to receive(:exec).with(array_including('sed'))
expect(test_container).to receive(:exec).with(%w[service sshd restart])
docker.send(:fix_ssh, test_container, host)
Expand Down

0 comments on commit 4769add

Please sign in to comment.