Skip to content

Commit 4075956

Browse files
committed
[API][Tests] Updates unit tests for API and perform_request_spec
1 parent 8c1ce1b commit 4075956

14 files changed

+49
-179
lines changed

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

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,15 @@
2222
let(:expected_args) do
2323
[
2424
'DELETE',
25-
'_search/scroll/abc123',
25+
'_search/scroll',
2626
{},
27-
nil,
27+
{ scroll_id: 'abc123' },
2828
{},
29-
{ defined_params: { scroll_id: 'abc123' }, endpoint: 'clear_scroll' }
29+
{ endpoint: 'clear_scroll' }
3030
]
3131
end
3232

3333
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
34+
expect(client_double.clear_scroll(body: { scroll_id: 'abc123' })).to be_a Elasticsearch::API::Response
5335
end
5436
end

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

Lines changed: 12 additions & 12 deletions
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

@@ -38,12 +38,12 @@
3838

3939
let(:expected_args) do
4040
[
41-
'POST',
42-
'_cluster/reroute',
43-
{},
44-
{ commands: [ move: { index: 'myindex', shard: 0 }] },
45-
{},
46-
{ endpoint: 'cluster.reroute' }
41+
'POST',
42+
'_cluster/reroute',
43+
{},
44+
{ commands: [ move: { index: 'myindex', shard: 0 }] },
45+
{},
46+
{ endpoint: 'cluster.reroute' }
4747
]
4848
end
4949

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

Lines changed: 4 additions & 5 deletions
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/indices/resolve_cluster_spec.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,6 @@
3030
]
3131
end
3232

33-
context 'when there is no name specified' do
34-
let(:client) do
35-
Class.new { include Elasticsearch::API }.new
36-
end
37-
38-
it 'raises an exception' do
39-
expect {
40-
client.indices.resolve_cluster
41-
}.to raise_exception(ArgumentError)
42-
end
43-
end
44-
45-
4633
context 'when name is specified' do
4734
it 'performs the request' do
4835
expect(client_double.indices.resolve_cluster(name: 'foo')).to be_a Elasticsearch::API::Response

elasticsearch-api/spec/unit/actions/inference/inference_spec.rb

Lines changed: 0 additions & 36 deletions
This file was deleted.

elasticsearch-api/spec/unit/actions/inference/put_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
let(:expected_args) do
2222
[
2323
'PUT',
24-
'_inference/foo/bar',
24+
'_inference/bar',
2525
{},
26-
nil,
2726
{},
28-
{ defined_params: { inference_id: 'bar', task_type: 'foo' },
27+
{},
28+
{ defined_params: { inference_id: 'bar' },
2929
endpoint: 'inference.put' }
3030
]
3131
end
3232

3333
it 'performs the request' do
34-
expect(client_double.inference.put(task_type: 'foo', inference_id: 'bar')).to be_a Elasticsearch::API::Response
34+
expect(client_double.inference.put(body: {}, inference_id: 'bar')).to be_a Elasticsearch::API::Response
3535
end
3636
end

elasticsearch-api/spec/unit/actions/inference/stream_inference_spec.rb

Lines changed: 0 additions & 35 deletions
This file was deleted.

elasticsearch-api/spec/unit/actions/inference/unified_inference_spec.rb

Lines changed: 0 additions & 36 deletions
This file was deleted.

elasticsearch-api/spec/unit/actions/inference/update_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
'PUT',
2424
'_inference/foo/bar/_update',
2525
{},
26-
nil,
26+
{},
2727
{},
2828
{ defined_params: { inference_id: 'bar', task_type: 'foo' },
2929
endpoint: 'inference.update' }
3030
]
3131
end
3232

3333
it 'performs the request' do
34-
expect(client_double.inference.update(task_type: 'foo', inference_id: 'bar')).to be_a Elasticsearch::API::Response
34+
expect(client_double.inference.update(task_type: 'foo', body: {}, inference_id: 'bar')).to be_a Elasticsearch::API::Response
3535
end
3636
end

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

Lines changed: 1 addition & 1 deletion
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' }

0 commit comments

Comments
 (0)