Skip to content

Commit 30282b5

Browse files
committed
[Test Runner] Updates perform_request_spec
Don't fail, log when methods are not implemented yet
1 parent a0fa608 commit 30282b5

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

elasticsearch-api/spec/unit/perform_request_spec.rb

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
require 'spec_helper'
1918
require 'elastic-transport'
19+
require 'spec_helper'
20+
2021
require_relative File.expand_path('../../utils/thor/endpoint_spec', __dir__)
2122
require_relative File.expand_path('../../utils/thor/generator/files_helper', __dir__)
2223

@@ -28,10 +29,23 @@
2829
# TODO: Once the test suite is migrated to elasticsearch-specification, these should be removed
2930
spec.module_namespace.flatten.first == 'rollup' ||
3031
[
31-
'scroll', 'clear_scroll', 'connector.last_sync', 'knn_search',
32-
'indices.remove_block'
32+
'scroll', 'clear_scroll', 'connector.last_sync', 'knn_search'
3333
].include?(spec.endpoint_name)
3434

35+
# Skip testing if the method hasn't been added to the client yet:
36+
client = Elasticsearch::Client.new
37+
implemented = if spec.module_namespace.empty?
38+
client.public_methods.include?(spec.method_name.to_sym)
39+
else
40+
client.public_methods.include?(spec.module_namespace[0].to_sym) &&
41+
client.send(spec.module_namespace[0]).methods.include?(spec.method_name.to_sym)
42+
end
43+
unless implemented
44+
name = spec.module_namespace.empty? ? spec.method_name : "#{spec.module_namespace[0]}.#{spec.method_name}"
45+
Logger.new($stdout).info("Method #{name} not implemented yet")
46+
next
47+
end
48+
3549
# These are the path parts defined by the user in the method argument
3650
defined_path_parts = spec.path_params.inject({}) do |params, part|
3751
params.merge(part => 'testing')
@@ -68,7 +82,7 @@
6882
end
6983

7084
if spec.path_parts.empty?
71-
it "passes the endpoint id to the request" do
85+
it 'passes the endpoint id to the request' do
7286
if spec.module_namespace.empty?
7387
client_double.send(spec.method_name, required_params)
7488
else
@@ -81,7 +95,9 @@
8195
client_double.send(spec.method_name, required_params.merge(defined_path_parts))
8296
else
8397
client_double.send(
84-
spec.module_namespace[0]).send(spec.method_name, required_params.merge(defined_path_parts)
98+
spec.module_namespace[0]
99+
).send(
100+
spec.method_name, required_params.merge(defined_path_parts)
85101
)
86102
end
87103
end

0 commit comments

Comments
 (0)