chef-apply 0.3.3 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/chef-apply.gemspec +2 -1
- data/lib/chef_apply/action/base.rb +1 -0
- data/lib/chef_apply/action/converge_target.rb +11 -11
- data/lib/chef_apply/action/converge_target/ccr_failure_mapper.rb +100 -0
- data/lib/chef_apply/action/generate_local_policy.rb +1 -1
- data/lib/chef_apply/action/generate_temp_cookbook.rb +53 -53
- data/lib/chef_apply/action/generate_temp_cookbook/recipe_lookup.rb +124 -0
- data/lib/chef_apply/action/generate_temp_cookbook/temp_cookbook.rb +175 -0
- data/lib/chef_apply/action/install_chef.rb +8 -8
- data/lib/chef_apply/action/install_chef/minimum_chef_version.rb +85 -0
- data/lib/chef_apply/cli.rb +10 -9
- data/lib/chef_apply/cli/options.rb +2 -2
- data/lib/chef_apply/cli/validation.rb +2 -1
- data/lib/chef_apply/file_fetcher.rb +1 -1
- data/lib/chef_apply/log.rb +4 -6
- data/lib/chef_apply/startup.rb +7 -4
- data/lib/chef_apply/target_host.rb +10 -5
- data/lib/chef_apply/target_host/linux.rb +1 -1
- data/lib/chef_apply/target_resolver.rb +3 -1
- data/lib/chef_apply/telemeter.rb +1 -1
- data/lib/chef_apply/text/error_translation.rb +1 -1
- data/lib/chef_apply/text/text_wrapper.rb +2 -1
- data/lib/chef_apply/ui/error_printer.rb +15 -13
- data/lib/chef_apply/ui/plain_text_element.rb +1 -2
- data/lib/chef_apply/ui/plain_text_header.rb +1 -1
- data/lib/chef_apply/ui/terminal.rb +4 -4
- data/lib/chef_apply/version.rb +1 -1
- data/spec/spec_helper.rb +43 -3
- data/spec/unit/action/base_spec.rb +2 -1
- data/spec/unit/{errors → action/converge_target}/ccr_failure_mapper_spec.rb +12 -9
- data/spec/unit/action/converge_target_spec.rb +21 -22
- data/spec/unit/action/generate_local_policy_spec.rb +5 -5
- data/spec/unit/{recipe_lookup_spec.rb → action/generate_temp_cookbook/recipe_lookup_spec.rb} +10 -10
- data/spec/unit/{temp_cookbook_spec.rb → action/generate_temp_cookbook/temp_cookbook_spec.rb} +23 -24
- data/spec/unit/action/generate_temp_cookbook_spec.rb +4 -6
- data/spec/unit/{minimum_chef_version_spec.rb → action/install_chef/minimum_chef_version_spec.rb} +13 -13
- data/spec/unit/action/install_chef_spec.rb +4 -4
- data/spec/unit/cli/options_spec.rb +17 -17
- data/spec/unit/cli/validation_spec.rb +6 -3
- data/spec/unit/cli_spec.rb +12 -9
- data/spec/unit/log_spec.rb +1 -1
- data/spec/unit/startup_spec.rb +11 -12
- data/spec/unit/target_host/windows_spec.rb +1 -1
- data/spec/unit/target_host_spec.rb +3 -2
- data/spec/unit/telemeter_spec.rb +5 -5
- data/spec/unit/text/error_translation_spec.rb +11 -7
- data/spec/unit/ui/error_printer_spec.rb +6 -7
- metadata +24 -11
- data/Gemfile.lock +0 -400
- data/lib/chef_apply/errors/ccr_failure_mapper.rb +0 -93
- data/lib/chef_apply/minimum_chef_version.rb +0 -79
- data/lib/chef_apply/recipe_lookup.rb +0 -117
- data/lib/chef_apply/temp_cookbook.rb +0 -170
data/lib/chef_apply/startup.rb
CHANGED
@@ -106,6 +106,7 @@ module ChefApply
|
|
106
106
|
|
107
107
|
def first_run_tasks
|
108
108
|
return if Dir.exist?(Config::WS_BASE_PATH)
|
109
|
+
|
109
110
|
create_default_config
|
110
111
|
setup_telemetry
|
111
112
|
end
|
@@ -129,7 +130,7 @@ module ChefApply
|
|
129
130
|
end
|
130
131
|
|
131
132
|
def start_telemeter_upload
|
132
|
-
ChefApply::Telemeter::Sender.start_upload_thread
|
133
|
+
ChefApply::Telemeter::Sender.start_upload_thread
|
133
134
|
end
|
134
135
|
|
135
136
|
def setup_workstation_user_directories
|
@@ -167,6 +168,7 @@ module ChefApply
|
|
167
168
|
next_arg = argv[index + 1]
|
168
169
|
raise ConfigPathNotProvided.new if next_arg.nil?
|
169
170
|
raise ConfigPathInvalid.new(next_arg) unless File.file?(next_arg) && File.readable?(next_arg)
|
171
|
+
|
170
172
|
return next_arg
|
171
173
|
end
|
172
174
|
end
|
@@ -178,9 +180,10 @@ module ChefApply
|
|
178
180
|
ChefApply::Log.info("Initialized logger")
|
179
181
|
|
180
182
|
ChefConfig.logger = ChefApply::Log
|
181
|
-
# Setting the config isn't enough, we need to ensure the logger is
|
182
|
-
#
|
183
|
-
|
183
|
+
# Setting the config isn't enough, we need to ensure the logger is
|
184
|
+
# initialized with our existing stream or automatic initialization
|
185
|
+
# will still go to stdout instead of the log file we opened.
|
186
|
+
Chef::Log.init(ChefApply::Log.stream)
|
184
187
|
Chef::Log.level = ChefApply::Log.level
|
185
188
|
end
|
186
189
|
|
@@ -25,7 +25,7 @@ module ChefApply
|
|
25
25
|
# These values may exist in .ssh/config but will be ignored by train
|
26
26
|
# in favor of its defaults unless we specify them explicitly.
|
27
27
|
# See #apply_ssh_config
|
28
|
-
SSH_CONFIG_OVERRIDE_KEYS =
|
28
|
+
SSH_CONFIG_OVERRIDE_KEYS = %i{user port proxy}.freeze
|
29
29
|
|
30
30
|
# We're borrowing a page from train here - because setting up a
|
31
31
|
# reliable connection for testing is a multi-step process,
|
@@ -34,7 +34,7 @@ module ChefApply
|
|
34
34
|
# OS, this instance will mix-in the supporting methods for the given platform;
|
35
35
|
# otherwise those methods will raise NotImplementedError.
|
36
36
|
def self.mock_instance(url, family: "unknown", name: "unknown",
|
37
|
-
|
37
|
+
release: "unknown", arch: "x86_64")
|
38
38
|
# Specifying sudo: false ensures that attempted operations
|
39
39
|
# don't fail because the mock platform doesn't support sudo
|
40
40
|
target_host = TargetHost.new(url, { sudo: false })
|
@@ -87,7 +87,7 @@ module ChefApply
|
|
87
87
|
connection_opts[:self_signed] = (opts_in[:ssl_verify] === false ? true : false)
|
88
88
|
end
|
89
89
|
|
90
|
-
|
90
|
+
%i{sudo_password sudo sudo_command password user}.each do |key|
|
91
91
|
connection_opts[key] = opts_in[key] if opts_in.key? key
|
92
92
|
end
|
93
93
|
|
@@ -114,6 +114,7 @@ module ChefApply
|
|
114
114
|
def connect!
|
115
115
|
# Keep existing connections
|
116
116
|
return unless @backend.nil?
|
117
|
+
|
117
118
|
@backend = train_connection.connection
|
118
119
|
@backend.wait_until_ready
|
119
120
|
|
@@ -146,6 +147,7 @@ module ChefApply
|
|
146
147
|
# Returns the user being used to connect. Defaults to train's default user if not specified
|
147
148
|
def user
|
148
149
|
return config[:user] unless config[:user].nil?
|
150
|
+
|
149
151
|
require "train/transports/ssh"
|
150
152
|
Train::Transports::SSH.default_options[:user][:default]
|
151
153
|
end
|
@@ -182,6 +184,7 @@ module ChefApply
|
|
182
184
|
if result.exit_status != 0
|
183
185
|
raise RemoteExecutionFailed.new(@config[:host], command, result)
|
184
186
|
end
|
187
|
+
|
185
188
|
result
|
186
189
|
end
|
187
190
|
|
@@ -209,9 +212,10 @@ module ChefApply
|
|
209
212
|
# be found.
|
210
213
|
def installed_chef_version
|
211
214
|
return @installed_chef_version if @installed_chef_version
|
215
|
+
|
212
216
|
# Note: In the case of a very old version of chef (that has no manifest - pre 12.0?)
|
213
217
|
# this will report as not installed.
|
214
|
-
manifest = read_chef_version_manifest
|
218
|
+
manifest = read_chef_version_manifest
|
215
219
|
|
216
220
|
# We split the version here because unstable builds install from)
|
217
221
|
# are in the form "Major.Minor.Build+HASH" which is not a valid
|
@@ -222,6 +226,7 @@ module ChefApply
|
|
222
226
|
def read_chef_version_manifest
|
223
227
|
manifest = fetch_file_contents(omnibus_manifest_path)
|
224
228
|
raise ChefNotInstalled.new if manifest.nil?
|
229
|
+
|
225
230
|
JSON.parse(manifest)
|
226
231
|
end
|
227
232
|
|
@@ -233,7 +238,7 @@ module ChefApply
|
|
233
238
|
#
|
234
239
|
# The base temp dir is cached and will only be created once per connection lifetime.
|
235
240
|
def temp_dir
|
236
|
-
dir = make_temp_dir
|
241
|
+
dir = make_temp_dir
|
237
242
|
chown(dir, user)
|
238
243
|
dir
|
239
244
|
end
|
@@ -35,6 +35,7 @@ module ChefApply
|
|
35
35
|
# them to account for ranges embedded in the target name.
|
36
36
|
def targets
|
37
37
|
return @targets unless @targets.nil?
|
38
|
+
|
38
39
|
expanded_urls = []
|
39
40
|
@split_targets.each do |target|
|
40
41
|
expanded_urls = (expanded_urls | expand_targets(target))
|
@@ -84,7 +85,7 @@ module ChefApply
|
|
84
85
|
end
|
85
86
|
|
86
87
|
def prefix_from_target(target)
|
87
|
-
if target =~
|
88
|
+
if target =~ %r{^(.+?)://(.*)}
|
88
89
|
# We'll store the existing prefix to avoid it interfering
|
89
90
|
# with the check further below.
|
90
91
|
if ChefApply::Config::SUPPORTED_PROTOCOLS.include? $1.downcase
|
@@ -115,6 +116,7 @@ module ChefApply
|
|
115
116
|
|
116
117
|
def do_parse(targets, depth = 0)
|
117
118
|
raise TooManyRanges.new(@current_target) if depth > 2
|
119
|
+
|
118
120
|
new_targets = []
|
119
121
|
done = false
|
120
122
|
targets.each do |target|
|
data/lib/chef_apply/telemeter.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
module ChefApply
|
19
19
|
module Text
|
20
20
|
class ErrorTranslation
|
21
|
-
ATTRIBUTES =
|
21
|
+
ATTRIBUTES = %i{decorations header footer stack log}.freeze
|
22
22
|
attr_reader :message, *ATTRIBUTES
|
23
23
|
|
24
24
|
def initialize(id, params: [])
|
@@ -31,6 +31,7 @@ module ChefApply
|
|
31
31
|
if k.class == Integer
|
32
32
|
raise MissingPlural.new(@tree.instance_variable_get(:@path), k)
|
33
33
|
end
|
34
|
+
|
34
35
|
k = k.to_sym
|
35
36
|
define_singleton_method k do |*args|
|
36
37
|
subtree = @tree.send(k, *args)
|
@@ -55,7 +56,7 @@ module ChefApply
|
|
55
56
|
def set_call_context
|
56
57
|
# TODO - this can vary (8 isn't always right) - inspect
|
57
58
|
@line = caller(8, 1).first
|
58
|
-
if @line =~
|
59
|
+
if @line =~ %r{.*/lib/(.*\.rb):(\d+)}
|
59
60
|
@line = "File: #{$1} Line: #{$2}"
|
60
61
|
end
|
61
62
|
end
|
@@ -55,7 +55,7 @@ module ChefApply::UI
|
|
55
55
|
e.jobs.each do |j|
|
56
56
|
wrapped = ChefApply::Errors::StandardErrorResolver.wrap_exception(j.exception, j.target_host)
|
57
57
|
ep = ErrorPrinter.new(wrapped)
|
58
|
-
msg = ep.format_body
|
58
|
+
msg = ep.format_body.tr("\n", " ").gsub(/ {2,}/, " ").chomp.strip
|
59
59
|
out.write("Host: #{j.target_host.hostname} ")
|
60
60
|
if ep.exception.respond_to? :id
|
61
61
|
out.write("Error: #{ep.exception.id}: ")
|
@@ -95,7 +95,7 @@ module ChefApply::UI
|
|
95
95
|
@command = exception.respond_to?(:command) ? exception.command : nil
|
96
96
|
@pastel = Pastel.new
|
97
97
|
@content = StringIO.new
|
98
|
-
@id = if exception.
|
98
|
+
@id = if exception.is_a? ChefApply::Error
|
99
99
|
exception.id
|
100
100
|
else
|
101
101
|
DEFAULT_ERROR_NO
|
@@ -117,7 +117,7 @@ module ChefApply::UI
|
|
117
117
|
|
118
118
|
def format_undecorated
|
119
119
|
@content << "\n"
|
120
|
-
@content << format_body
|
120
|
+
@content << format_body
|
121
121
|
if @command
|
122
122
|
@content << "\n"
|
123
123
|
@content << @command.usage
|
@@ -126,11 +126,11 @@ module ChefApply::UI
|
|
126
126
|
|
127
127
|
def format_decorated
|
128
128
|
@content << "\n"
|
129
|
-
@content << format_header
|
129
|
+
@content << format_header
|
130
130
|
@content << "\n\n"
|
131
|
-
@content << format_body
|
131
|
+
@content << format_body
|
132
132
|
@content << "\n"
|
133
|
-
@content << format_footer
|
133
|
+
@content << format_footer
|
134
134
|
@content << "\n"
|
135
135
|
end
|
136
136
|
|
@@ -139,9 +139,9 @@ module ChefApply::UI
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def format_body
|
142
|
-
if exception.
|
142
|
+
if exception.is_a? ChefApply::Error
|
143
143
|
format_workstation_exception
|
144
|
-
elsif exception.
|
144
|
+
elsif exception.is_a? Train::Error
|
145
145
|
format_train_exception
|
146
146
|
else
|
147
147
|
format_other_exception
|
@@ -152,7 +152,7 @@ module ChefApply::UI
|
|
152
152
|
if translation.log
|
153
153
|
if translation.stack
|
154
154
|
t.footer.both(ChefApply::Config.log.location,
|
155
|
-
|
155
|
+
ChefApply::Config.stack_trace_path)
|
156
156
|
else
|
157
157
|
t.footer.log_only(ChefApply::Config.log.location)
|
158
158
|
end
|
@@ -168,7 +168,7 @@ module ChefApply::UI
|
|
168
168
|
def add_backtrace_header(out, args)
|
169
169
|
out.write("\n#{"-" * 80}\n")
|
170
170
|
out.print("#{Time.now}: Error encountered while running the following:\n")
|
171
|
-
out.print(" #{args.join(
|
171
|
+
out.print(" #{args.join(" ")}\n")
|
172
172
|
out.print("Backtrace:\n")
|
173
173
|
end
|
174
174
|
|
@@ -179,10 +179,10 @@ module ChefApply::UI
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def self.error_summary(e)
|
182
|
-
if e.
|
182
|
+
if e.is_a? ChefApply::Error
|
183
183
|
# By convention, all of our defined messages have a short summary on the first line.
|
184
184
|
ChefApply::Text.errors.send(e.id).text(*e.params).split("\n").first
|
185
|
-
elsif e.
|
185
|
+
elsif e.is_a? String
|
186
186
|
e
|
187
187
|
else
|
188
188
|
if e.respond_to? :message
|
@@ -201,7 +201,7 @@ module ChefApply::UI
|
|
201
201
|
# TODO this gets moved to trainerrormapper or simply removed since
|
202
202
|
# many of these issues are now handled in the RemoteTarget::ConnectionFailure
|
203
203
|
def format_train_exception
|
204
|
-
backend, host = formatted_host
|
204
|
+
backend, host = formatted_host
|
205
205
|
if host.nil?
|
206
206
|
t.CHEFTRN002.text(exception.message)
|
207
207
|
else
|
@@ -215,6 +215,7 @@ module ChefApply::UI
|
|
215
215
|
|
216
216
|
def formatted_host
|
217
217
|
return nil if target_host.nil?
|
218
|
+
|
218
219
|
cfg = target_host.config
|
219
220
|
port = cfg[:port].nil? ? "" : ":#{cfg[:port]}"
|
220
221
|
user = cfg[:user].nil? ? "" : "#{cfg[:user]}@"
|
@@ -251,6 +252,7 @@ module ChefApply::UI
|
|
251
252
|
i = 1
|
252
253
|
while i <= backtrace1.size && i <= backtrace2.size
|
253
254
|
break if backtrace1[-i] != backtrace2[-i]
|
255
|
+
|
254
256
|
i += 1
|
255
257
|
end
|
256
258
|
backtrace1[0..-i]
|
@@ -51,9 +51,9 @@ module ChefApply
|
|
51
51
|
# keys :top :middle and :bottom can contain Strings that are used to
|
52
52
|
# indent the spinners. Ignored if message is blank
|
53
53
|
multispinner = get_multispinner.new("[:spinner] #{header}",
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
output: @location,
|
55
|
+
hide_cursor: true,
|
56
|
+
style: indent_style)
|
57
57
|
jobs.each do |job|
|
58
58
|
multispinner.register(spinner_prefix(job.prefix), hide_cursor: true) do |spinner|
|
59
59
|
reporter = StatusReporter.new(spinner, prefix: job.prefix, key: :status)
|
@@ -91,7 +91,7 @@ module ChefApply
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def show_cursor
|
94
|
-
TTY::Cursor.show
|
94
|
+
TTY::Cursor.show
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
data/lib/chef_apply/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -20,6 +20,46 @@ require "simplecov"
|
|
20
20
|
require "rspec/expectations"
|
21
21
|
require "support/matchers/output_to_terminal"
|
22
22
|
|
23
|
+
# class << Kernel
|
24
|
+
# alias :_require :require
|
25
|
+
# def require(*args)
|
26
|
+
#
|
27
|
+
# show = false
|
28
|
+
# args.each do |a|
|
29
|
+
# if a =~ /chef_apply.*/
|
30
|
+
# show = true
|
31
|
+
# break
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# $stderr.puts "from #{File.basename(caller[1])}: require: %s" % [args.inspect] if show
|
36
|
+
# _require(*args)
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# alias :_load :load
|
40
|
+
# def load(*args)
|
41
|
+
# show = false
|
42
|
+
# args.each do |a|
|
43
|
+
# if a =~ /chef_apply.*/
|
44
|
+
# show = true
|
45
|
+
# break
|
46
|
+
# end
|
47
|
+
# end
|
48
|
+
# $stderr.puts "from #{File.basename(caller[1])}: load: %s" % [args.inspect] if show
|
49
|
+
# _load(*args)
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# module Kernel
|
55
|
+
# def require(*args)
|
56
|
+
# Kernel.require(*args)
|
57
|
+
# end
|
58
|
+
# def load(*args)
|
59
|
+
# Kernel.load(*args)
|
60
|
+
# end
|
61
|
+
# end
|
62
|
+
|
23
63
|
RemoteExecResult = Struct.new(:exit_status, :stdout, :stderr)
|
24
64
|
|
25
65
|
class ChefApply::MockReporter
|
@@ -67,7 +107,7 @@ def assert_string_lookup(key, retval = "testvalue")
|
|
67
107
|
it "should look up string #{key}" do
|
68
108
|
top_level_method, *call_seq = key.split(".")
|
69
109
|
terminal_method = call_seq.pop
|
70
|
-
tmock = double
|
110
|
+
tmock = double
|
71
111
|
# Because ordering is important
|
72
112
|
# (eg calling errors.hello is different from hello.errors),
|
73
113
|
# we need to add this individually instead of using
|
@@ -102,8 +142,8 @@ RSpec.configure do |config|
|
|
102
142
|
end
|
103
143
|
|
104
144
|
config.before(:all) do
|
105
|
-
ChefApply::Log.setup
|
106
|
-
ChefApply::UI::Terminal.init(File.open(
|
145
|
+
ChefApply::Log.setup File::NULL, :error
|
146
|
+
ChefApply::UI::Terminal.init(File.open(File::NULL, "w"))
|
107
147
|
end
|
108
148
|
end
|
109
149
|
|
@@ -16,16 +16,16 @@
|
|
16
16
|
#
|
17
17
|
|
18
18
|
require "spec_helper"
|
19
|
-
require "chef_apply/
|
19
|
+
require "chef_apply/action/converge_target/ccr_failure_mapper"
|
20
20
|
|
21
|
-
RSpec.describe ChefApply::
|
21
|
+
RSpec.describe ChefApply::Action::ConvergeTarget::CCRFailureMapper do
|
22
22
|
let(:cause_line) { nil }
|
23
23
|
let(:resource) { "apt_package" }
|
24
24
|
let(:params) do
|
25
25
|
{ resource: resource, resource_name: "a-test-thing",
|
26
26
|
stderr: "an error", stdout: "other output" }
|
27
27
|
end
|
28
|
-
subject { ChefApply::
|
28
|
+
subject { ChefApply::Action::ConvergeTarget::CCRFailureMapper.new(cause_line, params) }
|
29
29
|
|
30
30
|
describe "#exception_args_from_cause" do
|
31
31
|
context "when resource properties have valid names but invalid values" do
|
@@ -45,14 +45,16 @@ RSpec.describe ChefApply::Errors::CCRFailureMapper do
|
|
45
45
|
it "returns a correct CHEFCCR004 when details are available" do
|
46
46
|
expect(subject.exception_args_from_cause).to eq(
|
47
47
|
["CHEFCCR004",
|
48
|
-
"Option force must be a kind of [TrueClass, FalseClass]! You passed \"purle\"."]
|
48
|
+
"Option force must be a kind of [TrueClass, FalseClass]! You passed \"purle\"."]
|
49
|
+
)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
context "And less detail is available" do
|
52
53
|
let(:cause_line) { "Chef::Exceptions::User: linux_user[marc] ((chef-client cookbook)::(chef-client recipe) line 1) had an error: Chef::Exceptions::User: Couldn't lookup integer GID for group name blah" }
|
53
54
|
it "returns a correct CHEFCCR002" do
|
54
55
|
expect(subject.exception_args_from_cause).to eq(
|
55
|
-
["CHEFCCR002", "Couldn't lookup integer GID for group name blah"]
|
56
|
+
["CHEFCCR002", "Couldn't lookup integer GID for group name blah"]
|
57
|
+
)
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
@@ -70,7 +72,8 @@ RSpec.describe ChefApply::Errors::CCRFailureMapper do
|
|
70
72
|
let(:cause_line) { "NoMethodError: undefined method `badresourceprop' for Chef::Resource::User::LinuxUser" }
|
71
73
|
it "returns a correct CHEFCCR006 " do
|
72
74
|
expect(subject.exception_args_from_cause).to eq(
|
73
|
-
["CHEFCCR006", "badresourceprop", "Chef::Resource::User::LinuxUser"]
|
75
|
+
["CHEFCCR006", "badresourceprop", "Chef::Resource::User::LinuxUser"]
|
76
|
+
)
|
74
77
|
end
|
75
78
|
end
|
76
79
|
end
|
@@ -79,7 +82,7 @@ RSpec.describe ChefApply::Errors::CCRFailureMapper do
|
|
79
82
|
context "when no cause is provided" do
|
80
83
|
let(:cause_line) { nil }
|
81
84
|
it "raises a RemoteChefRunFailedToResolveError" do
|
82
|
-
expect { subject.raise_mapped_exception! }.to raise_error(ChefApply::
|
85
|
+
expect { subject.raise_mapped_exception! }.to raise_error(ChefApply::Action::ConvergeTarget::CCRFailureMapper::RemoteChefRunFailedToResolveError)
|
83
86
|
|
84
87
|
end
|
85
88
|
end
|
@@ -88,14 +91,14 @@ RSpec.describe ChefApply::Errors::CCRFailureMapper do
|
|
88
91
|
context "but can't resolve it" do
|
89
92
|
let(:cause_line) { "unparseable mess" }
|
90
93
|
it "raises a RemoteChefClientRunFailedUnknownReason" do
|
91
|
-
expect { subject.raise_mapped_exception! }.to raise_error(ChefApply::
|
94
|
+
expect { subject.raise_mapped_exception! }.to raise_error(ChefApply::Action::ConvergeTarget::CCRFailureMapper::RemoteChefClientRunFailedUnknownReason)
|
92
95
|
end
|
93
96
|
end
|
94
97
|
|
95
98
|
context "and can resolve the cause" do
|
96
99
|
let(:cause_line) { "NoMethodError: undefined method `badresourceprop' for Chef::Resource::User::LinuxUser" }
|
97
100
|
it "raises a RemoteChefClientRunFailed" do
|
98
|
-
expect { subject.raise_mapped_exception! }.to raise_error(ChefApply::
|
101
|
+
expect { subject.raise_mapped_exception! }.to raise_error(ChefApply::Action::ConvergeTarget::CCRFailureMapper::RemoteChefClientRunFailed)
|
99
102
|
end
|
100
103
|
end
|
101
104
|
end
|