|
15 | 15 | # specific language governing permissions and limitations
|
16 | 16 | # under the License.
|
17 | 17 |
|
18 |
| -require 'spec_helper' |
19 | 18 | require 'elastic-transport'
|
| 19 | +require 'spec_helper' |
| 20 | + |
20 | 21 | require_relative File.expand_path('../../utils/thor/endpoint_spec', __dir__)
|
21 | 22 | require_relative File.expand_path('../../utils/thor/generator/files_helper', __dir__)
|
22 | 23 |
|
|
28 | 29 | # TODO: Once the test suite is migrated to elasticsearch-specification, these should be removed
|
29 | 30 | spec.module_namespace.flatten.first == 'rollup' ||
|
30 | 31 | [
|
31 |
| - 'scroll', 'clear_scroll', 'connector.last_sync', 'knn_search', |
32 |
| - 'indices.remove_block' |
| 32 | + 'scroll', 'clear_scroll', 'connector.last_sync', 'knn_search' |
33 | 33 | ].include?(spec.endpoint_name)
|
34 | 34 |
|
| 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 | + |
35 | 49 | # These are the path parts defined by the user in the method argument
|
36 | 50 | defined_path_parts = spec.path_params.inject({}) do |params, part|
|
37 | 51 | params.merge(part => 'testing')
|
|
68 | 82 | end
|
69 | 83 |
|
70 | 84 | 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 |
72 | 86 | if spec.module_namespace.empty?
|
73 | 87 | client_double.send(spec.method_name, required_params)
|
74 | 88 | else
|
|
81 | 95 | client_double.send(spec.method_name, required_params.merge(defined_path_parts))
|
82 | 96 | else
|
83 | 97 | 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) |
85 | 101 | )
|
86 | 102 | end
|
87 | 103 | end
|
|
0 commit comments