-
-
Save richo/2715109 to your computer and use it in GitHub Desktop.
Varnish::Test syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'varnish/test' | |
require 'threading' | |
# initializer | |
# | |
q_in = Threading::Queue.new | |
q_out = Threading::Queue.new | |
thread = Thread.new do |q| | |
Listener.new do |sock| | |
data = sock.recv | |
sock.write(SomeLookupThing.new(data)) | |
q.enq sock.recv | |
end | |
end | |
class HelloWorldTest < Varnish::Test::TestCase | |
def test_it_says_hello_world | |
backend = Varnish::Test::Backend.new | |
backend.expect :get, '/', do |env| | |
[ 200, {}, "Hello World" ] | |
end | |
Net::HTTP.host "localhost" do |req| | |
res = ret.get "/" | |
# Make assertions about res | |
end | |
rets = [] | |
4.times do | |
rets << Rack::Response.new q.deq | |
end | |
# response = @varnish.get '/' | |
# assert response.ok? | |
# assert_equal 'Hello World', response.body | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment