Skip to content

Commit

Permalink
Add test for basic post request.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Oct 3, 2024
1 parent b185db3 commit ca97946
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/async/http/client/post.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.

require "sus/fixtures/async/http"

APostRequest = Sus::Shared("a post request") do
include Sus::Fixtures::Async::HTTP::ServerContext

let(:app) do
::Protocol::HTTP::Middleware.for do |request|
::Protocol::HTTP::Response[200, {}, request.body]
end
end

it "can post a fixed length body" do
body = Protocol::HTTP::Body::Buffered.wrap(["Hello, World!"])

begin
response = client.post("/", body: body)

expect(response).to be(:success?)
expect(response.read).to be == "Hello, World!"
ensure
response&.finish
end
end
end

describe Async::HTTP::Protocol::HTTP10 do
it_behaves_like APostRequest
end

describe Async::HTTP::Protocol::HTTP11 do
it_behaves_like APostRequest
end

describe Async::HTTP::Protocol::HTTP2 do
it_behaves_like APostRequest
end

0 comments on commit ca97946

Please sign in to comment.