Skip to content

Commit 8b389cf

Browse files
estolfopicandocodigo
authored andcommitted
download artifacts for unit tests
1 parent db98144 commit 8b389cf

File tree

2 files changed

+85
-85
lines changed

2 files changed

+85
-85
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ jobs:
4040
- name: elasticsearch
4141
run: cd elasticsearch && bundle exec rake test:all
4242
- name: elasticsearch-api
43-
run: cd elasticsearch-api && bundle exec rake test:spec test:platinum:unit
43+
run: cd elasticsearch-api && rake download_artifacts[8.11.0-SNAPSHOT] && bundle exec rake test:spec test:platinum:unit
Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,86 @@
1-
# # Licensed to Elasticsearch B.V. under one or more contributor
2-
# # license agreements. See the NOTICE file distributed with
3-
# # this work for additional information regarding copyright
4-
# # ownership. Elasticsearch B.V. licenses this file to you under
5-
# # the Apache License, Version 2.0 (the "License"); you may
6-
# # not use this file except in compliance with the License.
7-
# # You may obtain a copy of the License at
8-
# #
9-
# # http://www.apache.org/licenses/LICENSE-2.0
10-
# #
11-
# # Unless required by applicable law or agreed to in writing,
12-
# # software distributed under the License is distributed on an
13-
# # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14-
# # KIND, either express or implied. See the License for the
15-
# # specific language governing permissions and limitations
16-
# # under the License.
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
178
#
18-
# require 'spec_helper'
19-
# require 'elastic-transport'
20-
# require_relative '../../../utils/endpoint_spec'
21-
# require_relative '../../../utils/thor/generator/files_helper'
9+
# http://www.apache.org/licenses/LICENSE-2.0
2210
#
23-
# describe 'Perform request args' do
24-
# Elasticsearch::API::FilesHelper.files.each do |filepath|
25-
# spec = Elasticsearch::API::EndpointSpec.new(filepath)
26-
# next if spec.module_namespace.flatten.first == '_internal'
27-
#
28-
# # These are the path parts defined by the user in the method argument
29-
# defined_path_parts = spec.path_params.inject({}) do |params, part|
30-
# params.merge(part => 'testing')
31-
# end
32-
#
33-
# # These are the required params, we must pass them to the method even when testing
34-
# required_params = spec.required_parts.inject({}) do |params, part|
35-
# params.merge(part.to_sym => 'testing')
36-
# end
37-
#
38-
# let(:client_double) do
39-
# Class.new { include Elasticsearch::API }.new.tap do |client|
40-
# expect(client).to receive(:perform_request) do |_, _, _, _, _, request_params|
41-
# # The create method ends up becoming an 'index' request
42-
# if expected_perform_request_params[:endpoint] == 'create'
43-
# expected_perform_request_params[:endpoint] = 'index'
44-
# end
45-
# # Check that the expected hash is passed to the perform_request method
46-
# expect(request_params).to eq(expected_perform_request_params)
47-
# end.and_return(response_double)
48-
# end
49-
# end
50-
#
51-
# let(:response_double) do
52-
# double('response', status: 200, body: {}, headers: {})
53-
# end
54-
#
55-
# context("'#{spec.endpoint_name}'") do
56-
# # The expected hash passed to perform_request contains the endpoint name and any defined path parts
57-
# let(:expected_perform_request_params) do
58-
# if defined_path_parts.empty?
59-
# { endpoint: spec.endpoint_name }
60-
# else
61-
# { endpoint: spec.endpoint_name, defined_params: defined_path_parts}
62-
# end
63-
# end
64-
#
65-
# if spec.path_parts.empty?
66-
# it "passes the endpoint id to the request" do
67-
# if spec.module_namespace.empty?
68-
# client_double.send(spec.method_name, required_params)
69-
# else
70-
# client_double.send(spec.module_namespace[0]).send(spec.method_name, required_params)
71-
# end
72-
# end
73-
# else
74-
# it "passes params to the request with the endpoint id: #{spec.path_parts.keys}" do
75-
# if spec.module_namespace.empty?
76-
# client_double.send(spec.method_name, required_params.merge(defined_path_parts))
77-
# else
78-
# client_double.send(
79-
# spec.module_namespace[0]).send(spec.method_name, required_params.merge(defined_path_parts)
80-
# )
81-
# end
82-
# end
83-
# end
84-
# end
85-
# end
86-
# end
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'spec_helper'
19+
require 'elastic-transport'
20+
require_relative '../../../utils/endpoint_spec'
21+
require_relative '../../../utils/thor/generator/files_helper'
22+
23+
describe 'Perform request args' do
24+
Elasticsearch::API::FilesHelper.files.each do |filepath|
25+
spec = Elasticsearch::API::EndpointSpec.new(filepath)
26+
next if spec.module_namespace.flatten.first == '_internal'
27+
28+
# These are the path parts defined by the user in the method argument
29+
defined_path_parts = spec.path_params.inject({}) do |params, part|
30+
params.merge(part => 'testing')
31+
end
32+
33+
# These are the required params, we must pass them to the method even when testing
34+
required_params = spec.required_parts.inject({}) do |params, part|
35+
params.merge(part.to_sym => 'testing')
36+
end
37+
38+
let(:client_double) do
39+
Class.new { include Elasticsearch::API }.new.tap do |client|
40+
expect(client).to receive(:perform_request) do |_, _, _, _, _, request_params|
41+
# The create method ends up becoming an 'index' request
42+
if expected_perform_request_params[:endpoint] == 'create'
43+
expected_perform_request_params[:endpoint] = 'index'
44+
end
45+
# Check that the expected hash is passed to the perform_request method
46+
expect(request_params).to eq(expected_perform_request_params)
47+
end.and_return(response_double)
48+
end
49+
end
50+
51+
let(:response_double) do
52+
double('response', status: 200, body: {}, headers: {})
53+
end
54+
55+
context("'#{spec.endpoint_name}'") do
56+
# The expected hash passed to perform_request contains the endpoint name and any defined path parts
57+
let(:expected_perform_request_params) do
58+
if defined_path_parts.empty?
59+
{ endpoint: spec.endpoint_name }
60+
else
61+
{ endpoint: spec.endpoint_name, defined_params: defined_path_parts}
62+
end
63+
end
64+
65+
if spec.path_parts.empty?
66+
it "passes the endpoint id to the request" do
67+
if spec.module_namespace.empty?
68+
client_double.send(spec.method_name, required_params)
69+
else
70+
client_double.send(spec.module_namespace[0]).send(spec.method_name, required_params)
71+
end
72+
end
73+
else
74+
it "passes params to the request with the endpoint id: #{spec.path_parts.keys}" do
75+
if spec.module_namespace.empty?
76+
client_double.send(spec.method_name, required_params.merge(defined_path_parts))
77+
else
78+
client_double.send(
79+
spec.module_namespace[0]).send(spec.method_name, required_params.merge(defined_path_parts)
80+
)
81+
end
82+
end
83+
end
84+
end
85+
end
86+
end

0 commit comments

Comments
 (0)