-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathfail_plan_spec.rb
More file actions
44 lines (35 loc) · 1.19 KB
/
fail_plan_spec.rb
File metadata and controls
44 lines (35 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true
require 'spec_helper'
require 'bolt/executor'
require 'bolt/error'
describe 'fail_plan' do
let(:tasks_enabled) { true }
let(:executor) { Bolt::Executor.new }
around(:each) do |example|
Puppet[:tasks] = tasks_enabled
Puppet.override(bolt_executor: executor) do
example.run
end
end
it 'raises an error from arguments' do
is_expected.to run.with_params('oops').and_raise_error(Bolt::PlanFailure)
end
it 'raises an error from an Error object' do
error = Puppet::DataTypes::Error.new('oops')
is_expected.to run.with_params(error).and_raise_error(Bolt::PlanFailure)
end
it 'reports the call to analytics' do
executor = Bolt::Executor.new
executor.expects(:report_function_call).with('fail_plan')
Puppet.override(bolt_executor: executor) do
is_expected.to run.with_params('foo').and_raise_error(Bolt::PlanFailure)
end
end
context 'without tasks enabled' do
let(:tasks_enabled) { false }
it 'fails and reports that fail_plan is not available' do
is_expected.to run.with_params('foo')
.and_raise_error(/Plan language function 'fail_plan' cannot be used/)
end
end
end