Skip to content

Commit cada444

Browse files
committed
Test Runner: Refactors perform action for header
1 parent 6f70d6b commit cada444

File tree

1 file changed

+7
-17
lines changed
  • elasticsearch-api/api-spec-testing/test_file

1 file changed

+7
-17
lines changed

elasticsearch-api/api-spec-testing/test_file/action.rb

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,24 +141,12 @@ def perform_action(method, args, client, test)
141141
@response = client.send(method, arguments)
142142
client
143143
when 'headers'
144-
headers = prepare_arguments(args, test)
145-
host = client.transport.instance_variable_get('@hosts')
146144
transport_options = client.transport.instance_variable_get('@options')&.dig(:transport_options) || {}
147-
if ENV['QUIET'] == 'true'
148-
# todo: create a method on Elasticsearch::Client that can clone the client with new options
149-
Elasticsearch::Client.new(
150-
host: host,
151-
transport_options: transport_options.merge(headers: headers)
152-
)
153-
else
154-
Elasticsearch::Client.new(
155-
host: host,
156-
tracer: Logger.new($stdout),
157-
transport_options: transport_options.merge(headers: headers)
158-
)
159-
end
160-
when 'catch', 'warnings', 'allowed_warnings', 'allowed_warnings_regex', 'warnings_regex'
161-
client
145+
Elasticsearch::Client.new(
146+
hosts: client.transport.hosts,
147+
tracer: client.transport.tracer || nil,
148+
transport_options: transport_options.merge(headers: prepare_arguments(args, test))
149+
)
162150
when 'put_trained_model_alias'
163151
args.merge!('reassign' => true) unless args['reassign'] === false
164152
@response = client.send(method, prepare_arguments(args, test))
@@ -187,6 +175,8 @@ def perform_action(method, args, client, test)
187175
end
188176
@response = client.send(method, prepare_arguments(args, test))
189177
client
178+
when 'catch', 'warnings', 'allowed_warnings', 'allowed_warnings_regex', 'warnings_regex'
179+
client
190180
else
191181
@response = client.send(method, prepare_arguments(args, test))
192182
client

0 commit comments

Comments
 (0)