Skip to content

Commit ca97946

Browse files
committed
Add test for basic post request.
1 parent b185db3 commit ca97946

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/async/http/client/post.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2018-2024, by Samuel Williams.
5+
6+
require "sus/fixtures/async/http"
7+
8+
APostRequest = Sus::Shared("a post request") do
9+
include Sus::Fixtures::Async::HTTP::ServerContext
10+
11+
let(:app) do
12+
::Protocol::HTTP::Middleware.for do |request|
13+
::Protocol::HTTP::Response[200, {}, request.body]
14+
end
15+
end
16+
17+
it "can post a fixed length body" do
18+
body = Protocol::HTTP::Body::Buffered.wrap(["Hello, World!"])
19+
20+
begin
21+
response = client.post("/", body: body)
22+
23+
expect(response).to be(:success?)
24+
expect(response.read).to be == "Hello, World!"
25+
ensure
26+
response&.finish
27+
end
28+
end
29+
end
30+
31+
describe Async::HTTP::Protocol::HTTP10 do
32+
it_behaves_like APostRequest
33+
end
34+
35+
describe Async::HTTP::Protocol::HTTP11 do
36+
it_behaves_like APostRequest
37+
end
38+
39+
describe Async::HTTP::Protocol::HTTP2 do
40+
it_behaves_like APostRequest
41+
end

0 commit comments

Comments
 (0)