Skip to content

Commit 8aec025

Browse files
committed
test: fix bolt-modules tests
1 parent 28ef0d8 commit 8aec025

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+87
-190
lines changed

bolt-modules/boltlib/Rakefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# frozen_string_literal: true
2+
3+
require 'voxpupuli/test/rake'

bolt-modules/boltlib/spec/functions/add_facts_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
require 'bolt/inventory'
66

77
describe 'add_facts' do
8-
include PuppetlabsSpec::Fixtures
9-
108
let(:executor) { Bolt::Executor.new }
119
let(:inventory) { Bolt::Inventory.empty }
1210
let(:target) { inventory.get_target('example') }

bolt-modules/boltlib/spec/functions/add_to_group_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
require 'bolt/inventory'
55

66
describe 'add_to_group' do
7-
include PuppetlabsSpec::Fixtures
8-
97
let(:executor) { Bolt::Executor.new }
108
let(:inventory) { Bolt::Inventory.empty }
119
let(:target) { inventory.get_target('example') }

bolt-modules/boltlib/spec/functions/apply_prep_spec.rb

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
require 'bolt/task'
1212

1313
describe 'apply_prep' do
14-
include PuppetlabsSpec::Fixtures
15-
1614
let(:applicator) { mock('Bolt::Applicator') }
1715
let(:config) { Bolt::Config.default }
1816
let(:executor) { Bolt::Executor.new }
@@ -32,9 +30,8 @@
3230
end
3331

3432
context 'with targets' do
35-
let(:hostnames) { %w[a.b.com winrm://x.y.com pcp://foo] }
33+
let(:hostnames) { %w[a.b.com winrm://x.y.com remote://foo] }
3634
let(:targets) { hostnames.map { |h| inventory.get_target(h) } }
37-
let(:unknown_targets) { targets.reject { |target| target.protocol == 'pcp' } }
3835
let(:fact) { { 'osfamily' => 'none' } }
3936
let(:custom_facts_task) { Bolt::Task.new('custom_facts_task') }
4037
let(:version_task) { Bolt::Task.new('openvox_bootstrap::check') }
@@ -74,7 +71,7 @@
7471

7572
is_expected.to run.with_params(hostnames.join(','))
7673
targets.each do |target|
77-
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
74+
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'remote'
7875
expect(inventory.facts(target)).to eq(fact)
7976
end
8077
end
@@ -92,7 +89,7 @@
9289

9390
is_expected.to run.with_params(hostnames, '_run_as' => 'root')
9491
targets.each do |target|
95-
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
92+
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'remote'
9693
expect(inventory.facts(target)).to eq(fact)
9794
end
9895
end
@@ -110,7 +107,7 @@
110107

111108
is_expected.to run.with_params(hostnames, '_noop' => true)
112109
targets.each do |target|
113-
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
110+
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'remote'
114111
expect(inventory.facts(target)).to eq(fact)
115112
end
116113
end
@@ -199,31 +196,6 @@
199196
end
200197
end
201198

202-
context 'with only pcp targets' do
203-
let(:hostnames) { %w[pcp://foo pcp://bar] }
204-
let(:targets) { hostnames.map { |h| inventory.get_target(h) } }
205-
let(:fact) { { 'osfamily' => 'none' } }
206-
let(:custom_facts_task) { Bolt::Task.new('custom_facts_task') }
207-
208-
before(:each) do
209-
applicator.stubs(:build_plugin_tarball).returns(:tarball)
210-
applicator.stubs(:custom_facts_task).returns(custom_facts_task)
211-
end
212-
213-
it 'sets feature and gathers facts' do
214-
facts = Bolt::ResultSet.new(targets.map { |t| Bolt::Result.new(t, value: fact) })
215-
executor.expects(:run_task)
216-
.with(targets, custom_facts_task, includes('plugins'), {})
217-
.returns(facts)
218-
219-
is_expected.to run.with_params(hostnames.join(','))
220-
targets.each do |target|
221-
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
222-
expect(inventory.facts(target)).to eq(fact)
223-
end
224-
end
225-
end
226-
227199
context 'with targets assigned the puppet-agent feature' do
228200
let(:hostnames) { %w[foo bar] }
229201
let(:targets) { hostnames.map { |h| inventory.get_target(h) } }

bolt-modules/boltlib/spec/functions/background_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
require 'bolt/plan_future'
77

88
describe 'background' do
9-
include PuppetlabsSpec::Fixtures
10-
119
let(:name) { "Pluralize" }
1210
let(:object) { "noodle" }
1311
let(:future) { Bolt::PlanFuture.new('foo', name, plan_id: 1234) }

bolt-modules/boltlib/spec/functions/download_file_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
require 'bolt/project'
99

1010
describe 'download_file' do
11-
include PuppetlabsSpec::Fixtures
12-
1311
let(:executor) { Bolt::Executor.new }
1412
let(:inventory) { mock('inventory') }
1513
let(:project) { Bolt::Project.default_project }

bolt-modules/boltlib/spec/functions/facts_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
require 'bolt/inventory'
66

77
describe 'facts' do
8-
include PuppetlabsSpec::Fixtures
9-
108
let(:executor) { Bolt::Executor.new }
119
let(:inventory) { Bolt::Inventory.empty }
1210
let(:hostname) { 'example' }

bolt-modules/boltlib/spec/functions/fail_plan_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
require 'bolt/error'
66

77
describe 'fail_plan' do
8-
include PuppetlabsSpec::Fixtures
9-
108
let(:tasks_enabled) { true }
119
let(:executor) { Bolt::Executor.new }
1210

bolt-modules/boltlib/spec/functions/get_resources_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
require 'bolt/task'
1010

1111
describe 'get_resources' do
12-
include PuppetlabsSpec::Fixtures
13-
1412
let(:applicator) { mock('Bolt::Applicator') }
1513
let(:executor) { Bolt::Executor.new }
1614
let(:inventory) { Bolt::Inventory.empty }
@@ -26,7 +24,7 @@
2624
end
2725

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

bolt-modules/boltlib/spec/functions/get_target_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
require 'bolt/inventory'
66

77
describe 'get_target' do
8-
include PuppetlabsSpec::Fixtures
9-
108
let(:executor) { Bolt::Executor.new }
119
let(:inventory) { Bolt::Inventory.empty }
1210
let(:tasks_enabled) { true }

0 commit comments

Comments
 (0)