Skip to content

Commit 613d565

Browse files
committed
[XPACK] Backports point in time test
1 parent 4b58bb1 commit 613d565

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

elasticsearch-xpack/lib/elasticsearch/xpack.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def respond_to_missing?(method_name, *args)
6666
end
6767

6868
def xpack
69-
@xpack_client ||= Elasticsearch::XPack::API::Client.new(self)
69+
@xpack ||= Elasticsearch::XPack::API::Client.new(self)
7070
end
7171

7272
def security

elasticsearch-xpack/test/test_helper.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
require 'ansi'
2828

29+
require 'elasticsearch/transport'
2930
require 'elasticsearch/xpack'
3031

3132
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
@@ -48,22 +49,31 @@ module Elasticsearch
4849
module Test
4950
class FakeClient
5051
def xpack
51-
@xpack_client ||= Elasticsearch::XPack::API::Client.new(self)
52+
@xpack ||= Elasticsearch::XPack::API::Client.new(self)
5253
end
5354

5455
def perform_request(method, path, params, body)
5556
puts "PERFORMING REQUEST:", "--> #{method.to_s.upcase} #{path} #{params} #{body}"
5657
FakeResponse.new(200, 'FAKE', {})
5758
end
59+
60+
# Top level methods:
61+
Elasticsearch::Transport::Client::TOP_LEVEL_METHODS.each do |method|
62+
define_method method do |*args|
63+
xpack.send(method, *args)
64+
end
65+
end
5866
end
5967

6068
FakeResponse = Struct.new(:status, :body, :headers) do
6169
def status
6270
values[0] || 200
6371
end
72+
6473
def body
6574
values[1] || '{}'
6675
end
76+
6777
def headers
6878
values[2] || {}
6979
end

elasticsearch-xpack/test/unit/open_point_in_time_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ class XPackOpenPointInTimeTest < Minitest::Test
4646

4747
subject.xpack.open_point_in_time(index: 'foo')
4848
end
49+
50+
should 'perform correct request in client root with index' do
51+
subject.expects(:perform_request).with do |method, url, params, body|
52+
assert_equal 'POST', method
53+
assert_equal 'foo/_pit', url
54+
assert_equal({}, params)
55+
assert_nil body
56+
true
57+
end.returns(FakeResponse.new)
58+
59+
subject.open_point_in_time(index: 'foo')
60+
end
4961
end
5062
end
5163
end

0 commit comments

Comments
 (0)