Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

(BKR-1254) Update for Unix::Host does not allow each #17

Merged
merged 2 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions beaker-module_install_helper.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# coding: utf-8

lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Expand Down
1 change: 1 addition & 0 deletions lib/beaker/module_install_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def install_module_dependencies(deps = nil)
# specified host(s) from the dependencies list in metadata.json
def install_module_dependencies_on(hsts, deps = nil)
hsts = [hsts] if hsts.is_a?(Hash)
hsts = [hsts] unless hsts.respond_to?(:each)
deps = deps.nil? ? module_dependencies_from_metadata : deps

fh = ENV['BEAKER_FORGE_HOST']
Expand Down
50 changes: 22 additions & 28 deletions spec/unit/beaker/module_install_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'spec_helper'

describe Beaker::ModuleInstallHelper do
context 'hosts_to_install_module_on' do
context 'on split master/agent setup' do
describe 'hosts_to_install_module_on' do
context 'with a split master/agent setup' do
let(:hosts) do
[
{ 'roles' => %w[master database dashboard classifier] },
Expand All @@ -15,7 +15,7 @@
end
end

context 'on split agent only setup' do
context 'with a split agent only setup' do
let(:hosts) { [{ 'roles' => ['agent'] }] }

it 'returns a node with master role' do
Expand All @@ -24,7 +24,7 @@
end
end

context 'module_name_from_metadata' do
describe 'module_name_from_metadata' do
let(:module_metadata) { { 'name' => 'puppetlabs-vcsrepo' } }

it 'Removes author from name' do
Expand All @@ -33,7 +33,7 @@
end
end

context 'module_metadata' do
describe 'module_metadata' do
before do
$module_source_dir = '/a/b/c/d'
allow(File).to receive(:exist?)
Expand All @@ -44,12 +44,12 @@
.and_return('{"name": "puppetlabs-vcsrepo"}')
end

it 'Returns hash with correct data' do
it 'returns hash with correct data' do
expect(module_metadata['name']).to eq('puppetlabs-vcsrepo')
end
end

context 'get_module_source_directory' do
describe 'get_module_source_directory' do
let(:call_stack) { ['/a/b/c/d/e/f/g/spec_helper_acceptance.rb'] }
let(:call_stack_no_metadata) { ['/test/test/test/spec_helper_acceptance.rb'] }

Expand All @@ -67,7 +67,7 @@
end
end

context 'install_module_on' do
describe 'install_module_on' do
let(:module_source_dir) { '/a/b/c/d' }
let(:host) { { 'roles' => %w[master database dashboard classifier] } }

Expand All @@ -92,7 +92,7 @@
end
end

context 'module_version_matching_requirement' do
describe 'module_version_matching_requirement' do
context 'with simple version requirement, no upper bound' do
it 'return latest matching version' do
res = module_version_from_requirement('puppetlabs-ntp', '= 6.0.0')
Expand All @@ -109,14 +109,14 @@
end
end

context 'module_dependencies_from_metadata' do
describe 'module_dependencies_from_metadata' do
before do
allow_any_instance_of(described_class)
.to receive(:module_metadata)
.and_return(input_metadata)
end

context 'multiple dependencies with versions' do
context 'with multiple dependencies with versions' do
let(:input_metadata) do
{
'name' => 'puppetlabs-vcsrepo',
Expand Down Expand Up @@ -145,7 +145,7 @@
end
end

context 'multiple dependencies without versions' do
context 'with multiple dependencies without versions' do
let(:input_metadata) do
{
'name' => 'puppetlabs-vcsrepo',
Expand All @@ -169,7 +169,7 @@
end
end

context 'empty dependencies' do
context 'with empty dependencies' do
let(:input_metadata) do
{
'name' => 'puppetlabs-vcsrepo',
Expand All @@ -184,7 +184,7 @@
end
end

context 'no dependencies' do
context 'with no dependencies' do
let(:input_metadata) { { 'name' => 'puppetlabs-vcsrepo' } }
let(:desired) { [] }

Expand All @@ -195,7 +195,7 @@
end
end

context 'version_requirements_from_string' do
describe 'version_requirements_from_string' do
context 'with simple version requirement containing lower bound' do
let(:lower_bound) { '>= 2.0.0' }

Expand All @@ -217,7 +217,7 @@
end
end

context 'forge_host' do
describe 'forge_host' do
context 'without env variables specified' do
it 'returns production forge host' do
allow(ENV).to receive(:[]).with('BEAKER_FORGE_HOST').and_return(nil)
Expand All @@ -235,7 +235,7 @@
end
end

context 'forge_api' do
describe 'forge_api' do
context 'without env variables specified' do
it 'returns production forge api' do
allow(ENV).to receive(:[]).with('BEAKER_FORGE_HOST').and_return(nil)
Expand All @@ -255,7 +255,7 @@
end
end

context 'install_module_dependencies_on' do
describe 'install_module_dependencies_on' do
before do
allow_any_instance_of(described_class)
.to receive(:module_metadata)
Expand All @@ -279,14 +279,12 @@
}
end

before do
it 'installs the modules' do
expect_any_instance_of(Beaker::DSL::InstallUtils::ModuleUtils)
.to receive(:install_puppet_module_via_pmt_on)
.with(a_host, dependency)
.exactly(1)
end

it 'installs the modules' do
install_module_dependencies_on(a_host)
end
end
Expand All @@ -305,7 +303,7 @@
let(:dependency1) { { module_name: 'puppetlabs-concat' } }
let(:dependency2) { { module_name: 'puppetlabs-stdlib' } }

before do
it 'installs both modules' do # rubocop:disable RSpec/ExampleLength,RSpec/MultipleExpectations
expect_any_instance_of(Beaker::DSL::InstallUtils::ModuleUtils)
.to receive(:install_puppet_module_via_pmt_on)
.with(a_host, dependency1)
Expand All @@ -315,28 +313,24 @@
.to receive(:install_puppet_module_via_pmt_on)
.with(a_host, dependency2)
.exactly(1)
end

it 'installs both modules' do
install_module_dependencies_on(a_host)
end
end
end

context 'install_module_from_forge_on' do
describe 'install_module_from_forge_on' do
let(:a_host) { { name: 'a_host' } }
let(:dependency) { { module_name: 'puppetlabs-stdlib', version: '4.14.0' } }
let(:input_module_name) { 'puppetlabs/stdlib' }
let(:input_module_version_requirement) { '>= 4.13.1 <= 4.14.0' }

before do
it 'installs the module' do
expect_any_instance_of(Beaker::DSL::InstallUtils::ModuleUtils)
.to receive(:install_puppet_module_via_pmt_on)
.with(a_host, dependency)
.exactly(1)
end

it 'installs the module' do
install_module_from_forge_on(a_host, input_module_name, input_module_version_requirement)
end
end
Expand Down