Skip to content

Commit

Permalink
Add spec for Socket#finalize flushes
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Aug 8, 2024
1 parent 8eb3e48 commit 5939837
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/std/socket/socket_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,28 @@ describe Socket, tags: "network" do
socket.close_on_exec?.should be_true
end
{% end %}

describe "#finalize" do
it "flushes" do
port = unused_local_port
server = Socket.tcp(Socket::Family::INET)
server.bind("127.0.0.1", port)
server.listen

spawn do
client = server.not_nil!.accept
client << "foo"
client.flush
client << "bar"
client.finalize
end

socket = Socket.tcp(Socket::Family::INET)
socket.connect(Socket::IPAddress.new("127.0.0.1", port))
socket.gets.should eq "foobar"
ensure
socket.try &.close
server.try &.close
end
end
end

0 comments on commit 5939837

Please sign in to comment.