|
| 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 |
0 commit comments