Skip to content

Commit abd73e7

Browse files
committed
[API] Updates unit tests for 68 APIs with required body
1 parent c73c440 commit abd73e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+178
-211
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
'DELETE',
2424
'_pit',
2525
{},
26-
nil,
26+
{},
2727
{},
2828
{ endpoint: 'close_point_in_time' }
2929
]
3030
end
3131

3232
it 'performs the request' do
33-
expect(client_double.close_point_in_time).to be_a Elasticsearch::API::Response
33+
expect(client_double.close_point_in_time(body: {})).to be_a Elasticsearch::API::Response
3434
end
3535
end

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121

2222
let(:expected_args) do
2323
[
24-
'GET',
24+
'POST',
2525
'_cluster/allocation/explain',
2626
{},
27-
nil,
27+
{},
2828
{},
2929
{ endpoint: 'cluster.allocation_explain' }
3030
]
3131
end
3232

3333
it 'performs the request' do
34-
expect(client_double.cluster.allocation_explain).to be_a Elasticsearch::API::Response
34+
expect(client_double.cluster.allocation_explain(body: {})).to be_a Elasticsearch::API::Response
3535
end
3636
end

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

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,18 @@
1818
require 'spec_helper'
1919

2020
describe 'client.cluster#reroute' do
21-
2221
let(:expected_args) do
2322
[
2423
'POST',
2524
'_cluster/reroute',
2625
{},
27-
nil,
26+
{ commands: [ move: { index: 'myindex', shard: 0 }] },
2827
{},
2928
{ endpoint: 'cluster.reroute' }
3029
]
3130
end
3231

3332
it 'performs the request' do
34-
expect(client_double.cluster.reroute).to be_a Elasticsearch::API::Response
35-
end
36-
37-
context 'when a body is specified' do
38-
let(:expected_args) do
39-
[
40-
'POST',
41-
'_cluster/reroute',
42-
{},
43-
{ commands: [ move: { index: 'myindex', shard: 0 }] },
44-
{},
45-
{ endpoint: 'cluster.reroute' }
46-
]
47-
end
48-
49-
it 'performs the request' do
50-
expect(client_double.cluster.reroute(body: { commands: [ move: { index: 'myindex', shard: 0 }] })).to be_a Elasticsearch::API::Response
51-
end
33+
expect(client_double.cluster.reroute(body: { commands: [ move: { index: 'myindex', shard: 0 }] })).to be_a Elasticsearch::API::Response
5234
end
5335
end

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,33 @@
2020
describe 'client#count' do
2121
let(:expected_args) do
2222
[
23-
'GET',
23+
'POST',
2424
'_count',
2525
{},
26-
nil,
26+
{},
2727
{},
2828
{ endpoint: 'count' }
2929
]
3030
end
3131

3232
it 'performs the request' do
33-
expect(client_double.count).to be_a Elasticsearch::API::Response
33+
expect(client_double.count(body: {})).to be_a Elasticsearch::API::Response
3434
end
3535

3636
context 'when an index and type are specified' do
3737
let(:expected_args) do
3838
[
39-
'GET',
39+
'POST',
4040
'foo,bar/_count',
4141
{},
42-
nil,
42+
{},
4343
{},
4444
{ defined_params: { index: ['foo', 'bar'] }, endpoint: 'count' }
4545
]
4646
end
4747

4848
it 'performs the request' do
49-
expect(client_double.count(index: ['foo','bar'])).to be_a Elasticsearch::API::Response
49+
expect(client_double.count(index: ['foo','bar'], body: {})).to be_a Elasticsearch::API::Response
5050
end
5151
end
5252

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
end
6565

6666
context 'when a query is provided' do
67-
let(:method) { 'GET' }
67+
let(:method) { 'POST' }
6868
let(:params) do
6969
{ q: 'abc123' }
7070
end
@@ -81,11 +81,11 @@
8181
end
8282

8383
let(:body) do
84-
nil
84+
{}
8585
end
8686

8787
it 'passes the query' do
88-
expect(client_double.explain(index: 'foo', id: '1', q: 'abc123')).to be_a Elasticsearch::API::Response
88+
expect(client_double.explain(index: 'foo', id: '1', q: 'abc123', body: {})).to be_a Elasticsearch::API::Response
8989
end
9090
end
9191

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121

2222
let(:expected_args) do
2323
[
24-
'GET',
25-
'foo/_field_caps',
26-
{ fields: 'bar' },
27-
nil,
28-
{},
29-
{ defined_params: { index: 'foo' }, endpoint: 'field_caps' }
24+
'POST',
25+
'foo/_field_caps',
26+
{ fields: 'bar' },
27+
{},
28+
{},
29+
{ defined_params: { index: 'foo' }, endpoint: 'field_caps' }
3030
]
3131
end
3232

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

elasticsearch-api/spec/unit/actions/fleet/search_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
describe 'client#fleet.search' do
2121
let(:expected_args) do
2222
[
23-
'GET',
23+
'POST',
2424
'foo/_fleet/_fleet_search',
2525
{},
26-
nil,
26+
{},
2727
{},
2828
{ defined_params: { index: 'foo' }, endpoint: 'fleet.search' }
2929
]
3030
end
3131

3232
it 'performs the request' do
33-
expect(client_double.fleet.search(index: 'foo')).to be_a Elasticsearch::API::Response
33+
expect(client_double.fleet.search(index: 'foo', body: {})).to be_a Elasticsearch::API::Response
3434
end
3535

3636
let(:client) do

elasticsearch-api/spec/unit/actions/graph/explore_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
describe 'client#eql.search' do
2121
let(:expected_args) do
2222
[
23-
'GET',
23+
'POST',
2424
'foo/_graph/explore',
2525
{},
26-
nil,
26+
{},
2727
{},
2828
{ defined_params: { index: 'foo' }, endpoint: 'graph.explore' }
2929
]
3030
end
3131

3232
it 'performs the request' do
33-
expect(client_double.graph.explore(index: 'foo')).to be_a Elasticsearch::API::Response
33+
expect(client_double.graph.explore(index: 'foo', body: {})).to be_a Elasticsearch::API::Response
3434
end
3535
end

elasticsearch-api/spec/unit/actions/index_lifecycle_management/move_to_step_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
'POST',
2424
'_ilm/move/foo',
2525
{},
26-
nil,
26+
{},
2727
{},
2828
{ defined_params: { index: 'foo' }, endpoint: 'ilm.move_to_step' }
2929
]
@@ -32,6 +32,6 @@
3232
let(:index) { 'foo' }
3333

3434
it 'performs the request' do
35-
expect(client_double.index_lifecycle_management.move_to_step(index: 'foo')).to be_a Elasticsearch::API::Response
35+
expect(client_double.index_lifecycle_management.move_to_step(index: 'foo', body: {})).to be_a Elasticsearch::API::Response
3636
end
3737
end

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
{ endpoint: 'indices.analyze' }
2929
]
3030
end
31-
let(:method) { 'GET' }
31+
let(:method) { 'POST' }
3232

3333
let(:body) do
34-
nil
34+
{}
3535
end
3636

3737
let(:url) do
@@ -43,7 +43,7 @@
4343
end
4444

4545
it 'performs the request' do
46-
expect(client_double.indices.analyze).to be_a Elasticsearch::API::Response
46+
expect(client_double.indices.analyze(body: {})).to be_a Elasticsearch::API::Response
4747
end
4848

4949
context 'when an index is specified' do
@@ -63,7 +63,7 @@
6363
end
6464

6565
it 'performs the request' do
66-
expect(client_double.indices.analyze(index: 'foo')).to be_a Elasticsearch::API::Response
66+
expect(client_double.indices.analyze(index: 'foo', body: {})).to be_a Elasticsearch::API::Response
6767
end
6868
end
6969

0 commit comments

Comments
 (0)