Skip to content

Commit 9265f65

Browse files
committed
Add test for X-Line-Retry-Key
1 parent 7626b89 commit 9265f65

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

spec/line/bot/client_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,35 @@ def generate_client
126126
messages = body[:messages]
127127
expect(messages[0]).to eq message
128128
end
129+
130+
it 'set X-Line-Retry-Key' do
131+
client = Line::Bot::Client.new do |config|
132+
config.channel_token = dummy_config[:channel_token]
133+
end
134+
135+
available_endpoints = [
136+
'/bot/message/push',
137+
'/bot/message/multicast',
138+
'/bot/message/narrowcast',
139+
'/bot/message/broadcast'
140+
]
141+
142+
available_endpoints.each do |available_endpoint|
143+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + available_endpoint
144+
stub_request(:post, uri_template).with do |request|
145+
expect(request.headers['X-Line-Retry-Key']).to eq '123e4567-e89b-12d3-a456-426614174000'
146+
end.to_return(body: '{}', status: 200)
147+
end
148+
149+
user_id = "user1"
150+
message = {
151+
type: "text",
152+
text: "Hello, world"
153+
}
154+
155+
client.push_message(user_id, message, {'X-Line-Retry-Key' => '123e4567-e89b-12d3-a456-426614174000'})
156+
client.multicast(user_id, message, {'X-Line-Retry-Key' => '123e4567-e89b-12d3-a456-426614174000'})
157+
client.narrowcast(message, headers: {'X-Line-Retry-Key' => '123e4567-e89b-12d3-a456-426614174000'})
158+
client.broadcast(message, {'X-Line-Retry-Key' => '123e4567-e89b-12d3-a456-426614174000'})
159+
end
129160
end

0 commit comments

Comments
 (0)