Skip to content

Commit 34fcf99

Browse files
committed
[CLIENT] Add unit test for headers
1 parent 33a9f8d commit 34fcf99

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

elasticsearch-transport/spec/elasticsearch/transport/client_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,18 @@
11331133
end
11341134
end
11351135
end
1136+
1137+
context 'when a header is set on an endpoint request' do
1138+
let(:client) { described_class.new(host: hosts) }
1139+
let(:headers) { { 'user-agent' => 'my ruby app' } }
1140+
1141+
it 'performs the request with the header' do
1142+
allow(client).to receive(:perform_request) { OpenStruct.new(body: '') }
1143+
expect { client.search(headers: headers) }.not_to raise_error
1144+
expect(client).to have_received(:perform_request)
1145+
.with('GET', '_search', {}, nil, headers)
1146+
end
1147+
end
11361148
end
11371149

11381150
context 'when the client connects to Elasticsearch' do

0 commit comments

Comments
 (0)