Skip to content

Instantly share code, notes, and snippets.

@richo
Forked from lox/varnishtest.rb
Created May 17, 2012 00:18
Show Gist options
  • Save richo/2715109 to your computer and use it in GitHub Desktop.
Save richo/2715109 to your computer and use it in GitHub Desktop.
Varnish::Test syntax
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