Skip to content

Commit 44a7f42

Browse files
committed
[API] Updates specs
1 parent 037bd13 commit 44a7f42

7 files changed

+53
-61
lines changed

elasticsearch-api/spec/unit/actions/clear_scroll_spec.rb

+4-23
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,18 @@
1818
require 'spec_helper'
1919

2020
describe 'client#clear_scroll' do
21-
2221
let(:expected_args) do
2322
[
2423
'DELETE',
25-
'_search/scroll/abc123',
24+
'_search/scroll',
2625
{},
27-
nil,
26+
{ scroll_id: 123 },
2827
{},
29-
{ defined_params: { scroll_id: 'abc123' }, endpoint: 'clear_scroll' }
28+
{ endpoint: 'clear_scroll' }
3029
]
3130
end
3231

3332
it 'performs the request' do
34-
expect(client_double.clear_scroll(scroll_id: 'abc123')).to be_a Elasticsearch::API::Response
35-
end
36-
37-
context 'when a list of scroll ids is provided' do
38-
39-
let(:expected_args) do
40-
[
41-
'DELETE',
42-
'_search/scroll/abc123,def456',
43-
{},
44-
nil,
45-
{},
46-
{ defined_params: { scroll_id: ['abc123', 'def456'] }, endpoint: 'clear_scroll' }
47-
]
48-
end
49-
50-
it 'performs the request' do
51-
expect(client_double.clear_scroll(scroll_id: ['abc123', 'def456'])).to be_a Elasticsearch::API::Response
52-
end
33+
expect(client_double.clear_scroll(body: { scroll_id: 123 })).to be_a Elasticsearch::API::Response
5334
end
5435
end

elasticsearch-api/spec/unit/actions/cluster/reroute_spec.rb

+12-13
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
let(:expected_args) do
2323
[
24-
'POST',
25-
'_cluster/reroute',
26-
{},
27-
{},
28-
{},
29-
{ endpoint: 'cluster.reroute' }
24+
'POST',
25+
'_cluster/reroute',
26+
{},
27+
nil,
28+
{},
29+
{ endpoint: 'cluster.reroute' }
3030
]
3131
end
3232

@@ -35,15 +35,14 @@
3535
end
3636

3737
context 'when a body is specified' do
38-
3938
let(:expected_args) do
4039
[
41-
'POST',
42-
'_cluster/reroute',
43-
{},
44-
{ commands: [ move: { index: 'myindex', shard: 0 }] },
45-
{},
46-
{ endpoint: 'cluster.reroute' }
40+
'POST',
41+
'_cluster/reroute',
42+
{},
43+
{ commands: [ move: { index: 'myindex', shard: 0 }] },
44+
{},
45+
{ endpoint: 'cluster.reroute' }
4746
]
4847
end
4948

elasticsearch-api/spec/unit/actions/indices/get_field_mapping_spec.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{},
2727
nil,
2828
{},
29-
{ endpoint: 'indices.get_field_mapping' }
29+
{ endpoint: 'indices.get_field_mapping', defined_params: { fields: 'foo' } }
3030
]
3131
end
3232

@@ -35,11 +35,10 @@
3535
end
3636

3737
it 'performs the request' do
38-
expect(client_double.indices.get_field_mapping(field: 'foo')).to be_a Elasticsearch::API::Response
38+
expect(client_double.indices.get_field_mapping(fields: 'foo')).to be_a Elasticsearch::API::Response
3939
end
4040

4141
context 'when an index is specified' do
42-
4342
let(:url) do
4443
'foo/_mapping/field/bam'
4544
end
@@ -51,12 +50,12 @@
5150
{},
5251
nil,
5352
{},
54-
{ defined_params: { index: 'foo' }, endpoint: 'indices.get_field_mapping' }
53+
{ defined_params: { index: 'foo', fields: 'bam' }, endpoint: 'indices.get_field_mapping' }
5554
]
5655
end
5756

5857
it 'performs the request' do
59-
expect(client_double.indices.get_field_mapping(index: 'foo', field: 'bam')).to be_a Elasticsearch::API::Response
58+
expect(client_double.indices.get_field_mapping(index: 'foo', fields: 'bam')).to be_a Elasticsearch::API::Response
6059
end
6160
end
6261
end

elasticsearch-api/spec/unit/actions/ingest/get_ip_location_database_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
[
2323
'GET',
2424
'_ingest/ip_location/database/foo',
25-
{},
25+
{ body: {} },
2626
nil,
2727
{},
2828
{ defined_params: { id: 'foo' }, endpoint: 'ingest.get_ip_location_database' }

elasticsearch-api/spec/unit/actions/mtermvectors_spec.rb

+25-16
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,35 @@
1818
require 'spec_helper'
1919

2020
describe 'client#mtermvectors' do
21-
let(:expected_args) do
22-
[
23-
'POST',
24-
'my-index/_mtermvectors',
25-
{},
26-
body,
27-
{},
28-
{ defined_params: { index: 'my-index' }, endpoint: 'mtermvectors' }
29-
]
30-
end
31-
32-
let(:body) do
33-
{ ids: [1, 2, 3] }
34-
end
21+
context 'in body' do
22+
let(:expected_args) do
23+
[
24+
'POST',
25+
'my-index/_mtermvectors',
26+
{},
27+
{ ids: [1, 2, 3] },
28+
{},
29+
{ defined_params: { index: 'my-index' }, endpoint: 'mtermvectors' }
30+
]
31+
end
3532

36-
it 'performs the request' do
37-
expect(client_double.mtermvectors(index: 'my-index', body: { ids: [1, 2, 3] })).to be_a Elasticsearch::API::Response
33+
it 'performs the request' do
34+
expect(client_double.mtermvectors(index: 'my-index', body: { ids: [1, 2, 3] })).to be_a Elasticsearch::API::Response
35+
end
3836
end
3937

4038
context 'when a list of ids is passed instead of a body' do
39+
let(:expected_args) do
40+
[
41+
'GET',
42+
'my-index/_mtermvectors',
43+
{ ids: '1,2,3' },
44+
nil,
45+
{},
46+
{ defined_params: { index: 'my-index' }, endpoint: 'mtermvectors' }
47+
]
48+
end
49+
4150
it 'performs the request' do
4251
expect(client_double.mtermvectors(index: 'my-index', ids: [1, 2, 3])).to be_a Elasticsearch::API::Response
4352
end

elasticsearch-api/spec/unit/actions/scroll_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
let(:expected_args) do
2323
[
2424
'GET',
25-
'_search/scroll/cXVlcn...',
25+
'_search/scroll',
2626
{},
2727
nil,
2828
{},
29-
{ defined_params: { scroll_id: 'cXVlcn...' }, endpoint: 'scroll' }
29+
{ endpoint: 'scroll' }
3030
]
3131
end
3232

elasticsearch-api/spec/unit/perform_request_spec.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
describe 'Perform request args' do
2424
Elasticsearch::API::FilesHelper.files.each do |filepath|
2525
spec = Elasticsearch::API::EndpointSpec.new(filepath)
26-
next if spec.module_namespace.flatten.first == '_internal' || spec.visibility != 'public'
26+
next if spec.module_namespace.flatten.first == '_internal' ||
27+
spec.visibility != 'public' ||
28+
# TODO: Once the test suite is migrated to elasticsearch-specification, these should be removed
29+
spec.module_namespace.flatten.first == 'rollup' ||
30+
['scroll', 'clear_scroll', 'connector.last_sync'].include?(spec.endpoint_name)
2731

2832
# These are the path parts defined by the user in the method argument
2933
defined_path_parts = spec.path_params.inject({}) do |params, part|

0 commit comments

Comments
 (0)