Skip to content
Closed
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
3 changes: 3 additions & 0 deletions bolt-modules/boltlib/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require 'voxpupuli/test/rake'
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/add_facts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
require 'bolt/inventory'

describe 'add_facts' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
let(:target) { inventory.get_target('example') }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/add_to_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
require 'bolt/inventory'

describe 'add_to_group' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
let(:target) { inventory.get_target('example') }
Expand Down
36 changes: 4 additions & 32 deletions bolt-modules/boltlib/spec/functions/apply_prep_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
require 'bolt/task'

describe 'apply_prep' do
include PuppetlabsSpec::Fixtures

let(:applicator) { mock('Bolt::Applicator') }
let(:config) { Bolt::Config.default }
let(:executor) { Bolt::Executor.new }
Expand All @@ -32,9 +30,8 @@
end

context 'with targets' do
let(:hostnames) { %w[a.b.com winrm://x.y.com pcp://foo] }
let(:hostnames) { %w[a.b.com winrm://x.y.com remote://foo] }
let(:targets) { hostnames.map { |h| inventory.get_target(h) } }
let(:unknown_targets) { targets.reject { |target| target.protocol == 'pcp' } }
let(:fact) { { 'osfamily' => 'none' } }
let(:custom_facts_task) { Bolt::Task.new('custom_facts_task') }
let(:version_task) { Bolt::Task.new('openvox_bootstrap::check') }
Expand All @@ -61,7 +58,7 @@
Puppet::Pal::ScriptCompiler.any_instance.stubs(:task_signature).with('service').returns(task3)
end

it 'sets puppet-agent feature and gathers facts' do

Check failure on line 61 in bolt-modules/boltlib/spec/functions/apply_prep_spec.rb

View workflow job for this annotation

GitHub Actions / Test vendored Modules - ubuntu-24.04

apply_prep with targets sets puppet-agent feature and gathers facts Failure/Error: executor.stubs(:noop).returns(false) Mocha::NotInitializedError: Mocha methods cannot be used outside the context of a test
facts = Bolt::ResultSet.new(targets.map { |t| Bolt::Result.new(t, value: fact) })
executor.expects(:run_task)
.with(anything, custom_facts_task, includes('plugins'), {})
Expand All @@ -74,12 +71,12 @@

is_expected.to run.with_params(hostnames.join(','))
targets.each do |target|
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'remote'
expect(inventory.facts(target)).to eq(fact)
end
end

it 'escalates if provided _run_as' do

Check failure on line 79 in bolt-modules/boltlib/spec/functions/apply_prep_spec.rb

View workflow job for this annotation

GitHub Actions / Test vendored Modules - ubuntu-24.04

apply_prep with targets escalates if provided _run_as Failure/Error: executor.stubs(:noop).returns(false) Mocha::NotInitializedError: Mocha methods cannot be used outside the context of a test
facts = Bolt::ResultSet.new(targets.map { |t| Bolt::Result.new(t, value: fact) })
executor.expects(:run_task)
.with(anything, custom_facts_task, includes('plugins'), '_run_as' => 'root')
Expand All @@ -92,12 +89,12 @@

is_expected.to run.with_params(hostnames, '_run_as' => 'root')
targets.each do |target|
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'remote'
expect(inventory.facts(target)).to eq(fact)
end
end

it 'ignores unsupported metaparameters' do

Check failure on line 97 in bolt-modules/boltlib/spec/functions/apply_prep_spec.rb

View workflow job for this annotation

GitHub Actions / Test vendored Modules - ubuntu-24.04

apply_prep with targets ignores unsupported metaparameters Failure/Error: executor.stubs(:noop).returns(false) Mocha::NotInitializedError: Mocha methods cannot be used outside the context of a test
facts = Bolt::ResultSet.new(targets.map { |t| Bolt::Result.new(t, value: fact) })
executor.expects(:run_task)
.with(anything, custom_facts_task, includes('plugins'), {})
Expand All @@ -110,7 +107,7 @@

is_expected.to run.with_params(hostnames, '_noop' => true)
targets.each do |target|
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'remote'
expect(inventory.facts(target)).to eq(fact)
end
end
Expand Down Expand Up @@ -199,31 +196,6 @@
end
end

context 'with only pcp targets' do
let(:hostnames) { %w[pcp://foo pcp://bar] }
let(:targets) { hostnames.map { |h| inventory.get_target(h) } }
let(:fact) { { 'osfamily' => 'none' } }
let(:custom_facts_task) { Bolt::Task.new('custom_facts_task') }

before(:each) do
applicator.stubs(:build_plugin_tarball).returns(:tarball)
applicator.stubs(:custom_facts_task).returns(custom_facts_task)
end

it 'sets feature and gathers facts' do
facts = Bolt::ResultSet.new(targets.map { |t| Bolt::Result.new(t, value: fact) })
executor.expects(:run_task)
.with(targets, custom_facts_task, includes('plugins'), {})
.returns(facts)

is_expected.to run.with_params(hostnames.join(','))
targets.each do |target|
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
expect(inventory.facts(target)).to eq(fact)
end
end
end

context 'with targets assigned the puppet-agent feature' do
let(:hostnames) { %w[foo bar] }
let(:targets) { hostnames.map { |h| inventory.get_target(h) } }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/background_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
require 'bolt/plan_future'

describe 'background' do
include PuppetlabsSpec::Fixtures

let(:name) { "Pluralize" }
let(:object) { "noodle" }
let(:future) { Bolt::PlanFuture.new('foo', name, plan_id: 1234) }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/download_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
require 'bolt/project'

describe 'download_file' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { mock('inventory') }
let(:project) { Bolt::Project.default_project }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/facts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
require 'bolt/inventory'

describe 'facts' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
let(:hostname) { 'example' }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/fail_plan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
require 'bolt/error'

describe 'fail_plan' do
include PuppetlabsSpec::Fixtures

let(:tasks_enabled) { true }
let(:executor) { Bolt::Executor.new }

Expand Down
4 changes: 1 addition & 3 deletions bolt-modules/boltlib/spec/functions/get_resources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
require 'bolt/task'

describe 'get_resources' do
include PuppetlabsSpec::Fixtures

let(:applicator) { mock('Bolt::Applicator') }
let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
Expand All @@ -26,7 +24,7 @@
end

context 'with targets' do
let(:hostnames) { %w[a.b.com winrm://x.y.com pcp://foo] }
let(:hostnames) { %w[a.b.com winrm://x.y.com] }
let(:targets) { hostnames.map { |h| inventory.get_target(h) } }
let(:query_resources_task) { Bolt::Task.new('query_resources_task') }

Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/get_target_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
require 'bolt/inventory'

describe 'get_target' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
let(:tasks_enabled) { true }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/parallelize_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
require 'bolt/plan_result'

describe 'parallelize' do
include PuppetlabsSpec::Fixtures

let(:array) { %w[a b c d a b a] }
let(:future) { Bolt::PlanFuture.new(nil, 1, name: 'name', plan_id: 1234) }
let(:executor) { Bolt::Executor.new }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/puppetdb_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
require 'bolt/executor'

describe 'puppetdb_command' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:pdb_client) { mock('pdb_client') }
let(:tasks) { true }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/puppetdb_fact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
require 'spec_helper'

describe 'puppetdb_fact' do
include PuppetlabsSpec::Fixtures

let(:pdb_client) { mock('pdb_client') }

around(:each) do |example|
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/puppetdb_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
require 'spec_helper'

describe 'puppetdb_query' do
include PuppetlabsSpec::Fixtures

let(:pdb_client) { mock('pdb_client') }

around(:each) do |example|
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/remove_from_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

describe 'remove_from_group' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:config) { Bolt::Config.default }
let(:pal) { nil }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
require 'bolt/plugin'

describe 'resolve_references' do
include PuppetlabsSpec::Fixtures

let(:project) { Bolt::Project.create_project('./spec/fixtures') }
let(:config) { Bolt::Config.new(project, {}) }
let(:pal) {
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/run_plan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
require 'puppet/pops/types/p_sensitive_type'

describe 'run_plan' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:tasks_enabled) { true }
let(:inventory) { Bolt::Inventory.empty }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/run_script_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
require 'bolt/result_set'

describe 'run_script' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { mock('inventory') }
let(:tasks_enabled) { true }
Expand Down
20 changes: 0 additions & 20 deletions bolt-modules/boltlib/spec/functions/run_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ def matches?(available_parameters)
end

describe 'run_task' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
let(:tasks_enabled) { true }
Expand Down Expand Up @@ -399,24 +397,6 @@ def mock_task(executable, input_method)
.and_return(result_set)
end
end

context 'using the pcp transport' do
let(:task_name) { 'Test::Noop' }
let(:hostname) { 'pcp://a.b.com' }
let(:task_params) { { '_noop' => true } }

it 'sets the noop metaparameter when running in noop mode' do
executor.expects(:run_task).with([target],
anything,
{ '_noop' => true },
{ noop: true },
[])
.returns(result_set)

is_expected.to run
.with_params(task_name, hostname, task_params)
end
end
end

context 'running in parallel' do
Expand Down
21 changes: 0 additions & 21 deletions bolt-modules/boltlib/spec/functions/run_task_with_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def matches?(available_parameters)
end

describe 'run_task_with' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
let(:tasks_enabled) { true }
Expand Down Expand Up @@ -395,25 +393,6 @@ def mock_task(executable, input_method)
.and_return(result_set)
end
end

context 'using the pcp transport' do
let(:task_name) { 'Test::Noop' }
let(:hostname) { 'pcp://a.b.com' }
let(:hostname2) { 'pcp://x.y.com' }
let(:task_params) { { '_noop' => true } }

it 'sets the noop metaparameter when running in noop mode' do
executor.expects(:run_task_with)
.with(target_mapping, anything, { noop: true }, [])
.returns(result_set)
inventory.expects(:get_targets).with(hosts).returns(targets)

is_expected.to run
.with_params('Test::Noop', hosts, '_noop' => true)
.with_lambda { |_| {} }
.and_return(result_set)
end
end
end

context 'it validates the task parameters' do
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/set_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
require 'bolt/inventory'

describe 'set_config' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
let(:target) { inventory.get_target('example') }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/set_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
require 'bolt/inventory'

describe 'set_feature' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
let(:target) { inventory.get_target('example') }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/set_var_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
require 'bolt/inventory'

describe 'set_var' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
let(:target) { inventory.get_target('example') }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/upload_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
require 'bolt/target'

describe 'upload_file' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { mock('inventory') }
let(:tasks_enabled) { true }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/vars_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
require 'bolt/inventory'

describe 'vars' do
include PuppetlabsSpec::Fixtures

let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
let(:hostname) { 'example' }
Expand Down
2 changes: 0 additions & 2 deletions bolt-modules/boltlib/spec/functions/wait_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
require 'bolt/plan_future'

describe 'wait' do
include PuppetlabsSpec::Fixtures

let(:name) { "Pluralize" }
let(:future) { Bolt::PlanFuture.new('foo', name, plan_id: 1234) }
let(:executor) { Bolt::Executor.new }
Expand Down
11 changes: 2 additions & 9 deletions bolt-modules/boltlib/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# frozen_string_literal: true

require 'puppet_pal'
require 'bolt/pal'
require_relative '../../shared_spec_helper'

# Ensure tasks are enabled when rspec-puppet sets up an environment
# so we get task loaders.
Puppet[:tasks] = true
Bolt::PAL.load_puppet
RSpec.configure do |c|
c.mock_with :mocha
end
configure_rspec_for_this_module!(with_bolt_pal: true)

Check failure on line 5 in bolt-modules/boltlib/spec/spec_helper.rb

View workflow job for this annotation

GitHub Actions / rubocop_and_matrix

Layout/TrailingEmptyLines: Final newline missing. (https://rubystyle.guide#newline-eof)
3 changes: 3 additions & 0 deletions bolt-modules/ctrl/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require 'voxpupuli/test/rake'
9 changes: 2 additions & 7 deletions bolt-modules/ctrl/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require 'puppet_pal'
require_relative '../../shared_spec_helper'

# Ensure tasks are enabled when rspec-puppet sets up an environment
# so we get task loaders.
Puppet[:tasks] = true
RSpec.configure do |c|
c.mock_with :mocha
end
configure_rspec_for_this_module!
3 changes: 3 additions & 0 deletions bolt-modules/dir/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require 'voxpupuli/test/rake'
Loading
Loading