Skip to content

Commit d560de8

Browse files
committed
[API] Tests: Renames integration tests helper, updates some unit tests
1 parent 7189655 commit d560de8

File tree

7 files changed

+123
-15
lines changed

7 files changed

+123
-15
lines changed

elasticsearch-api/spec/integration/api_key_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# under the License.
1919

2020
require 'base64'
21-
require_relative './spec_helper'
21+
require_relative './integration_helper'
2222

2323
describe 'API keys' do
2424
before do

elasticsearch-api/spec/integration/health_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20-
require_relative './spec_helper'
20+
require_relative './integration_helper'
2121

2222
describe 'Health basic test' do
2323
it 'performs the request' do

elasticsearch-api/spec/unit/actions/nodes/info_spec.rb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
require 'spec_helper'
1919

2020
describe 'client.nodes#info' do
21-
2221
let(:expected_args) do
2322
[
24-
'GET',
25-
url,
26-
params,
27-
nil,
28-
{},
29-
{ endpoint: 'nodes.info' }
23+
'GET',
24+
url,
25+
params,
26+
nil,
27+
{},
28+
{ endpoint: 'nodes.info' }
3029
]
3130
end
3231

@@ -43,7 +42,6 @@
4342
end
4443

4544
context 'when the node id is specified' do
46-
4745
let(:url) do
4846
'_nodes/foo'
4947
end
@@ -65,7 +63,6 @@
6563
end
6664

6765
context 'when multiple node ids are specified as a list' do
68-
6966
let(:url) do
7067
'_nodes/A,B,C'
7168
end
@@ -87,7 +84,6 @@
8784
end
8885

8986
context 'when multiple node ids are specified as a String' do
90-
9187
let(:url) do
9288
'_nodes/A,B,C'
9389
end
@@ -109,7 +105,6 @@
109105
end
110106

111107
context 'when URL params are specified' do
112-
113108
let(:url) do
114109
'_nodes'
115110
end
@@ -124,7 +119,6 @@
124119
end
125120

126121
context 'when metrics are specified' do
127-
128122
let(:url) do
129123
'_nodes/http,network'
130124
end
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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.
17+
18+
require 'spec_helper'
19+
20+
describe 'client.nodes#usage' do
21+
let(:expected_args) do
22+
[
23+
'GET',
24+
url,
25+
params,
26+
nil,
27+
{},
28+
{ endpoint: 'nodes.usage' }
29+
]
30+
end
31+
32+
let(:url) do
33+
'_nodes/usage'
34+
end
35+
36+
it 'performs the request' do
37+
expect(client_double.nodes.usage).to be_a Elasticsearch::API::Response
38+
end
39+
40+
let(:params) do
41+
{}
42+
end
43+
44+
context 'when the node id is specified' do
45+
let(:url) do
46+
'_nodes/foo/usage'
47+
end
48+
49+
let(:expected_args) do
50+
[
51+
'GET',
52+
url,
53+
params,
54+
nil,
55+
{},
56+
{ defined_params: { node_id: 'foo' }, endpoint: 'nodes.usage' }
57+
]
58+
end
59+
60+
it 'performs the request' do
61+
expect(client_double.nodes.usage(node_id: 'foo')).to be_a Elasticsearch::API::Response
62+
end
63+
end
64+
65+
context 'when the metric is specified' do
66+
let(:url) do
67+
'_nodes/usage/metric'
68+
end
69+
70+
let(:expected_args) do
71+
[
72+
'GET',
73+
url,
74+
params,
75+
nil,
76+
{},
77+
{ defined_params: { metric: 'metric' }, endpoint: 'nodes.usage' }
78+
]
79+
end
80+
81+
it 'performs the request' do
82+
expect(client_double.nodes.usage(metric: 'metric')).to be_a Elasticsearch::API::Response
83+
end
84+
end
85+
86+
context 'when both are specified' do
87+
let(:url) do
88+
'_nodes/foo/usage/metric'
89+
end
90+
91+
let(:expected_args) do
92+
[
93+
'GET',
94+
url,
95+
params,
96+
nil,
97+
{},
98+
{ defined_params: { node_id: 'foo', metric: 'metric' }, endpoint: 'nodes.usage' }
99+
]
100+
end
101+
102+
it 'performs the request' do
103+
expect(client_double.nodes.usage(metric: 'metric', node_id: 'foo')).to be_a Elasticsearch::API::Response
104+
end
105+
end
106+
end

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@
7272
end
7373

7474
it 'performs the request' do
75-
expect(client_double.termvector(index: 'foo', id: '123', body: {})).to be_a Elasticsearch::API::Response
75+
message = '[DEPRECATION] `termvector` is deprecated. Please use the plural version, `termvectors` instead.
76+
'
77+
expect do
78+
client_double.termvector(index: 'foo', id: '123', body: {})
79+
end.to output(message).to_stderr
7680
end
7781
end
7882
end

elasticsearch-api/spec/unit/api_response_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,8 @@
6262
it 'returns the body which' do
6363
expect(response.body).to eq response_body
6464
end
65+
66+
it 'returns the body with to_s' do
67+
expect(response.to_s).to eq response.body.to_s
68+
end
6569
end

0 commit comments

Comments
 (0)