(module proxy-test mzscheme
   (lib "" "net")
   (lib "" "net")

   (planet "" ("schematics" "schemeunit.plt" 2))
   (file ""))
  (provide proxy-tests)

  (define (request->path method url headers)
    (cond [(regexp-match #rx#"local.html$" url)
           (string->path "local.html")]
          [else #f]))
  ;; Assume all connections go through the proxy
  (define shutdown-proxy
    (run-proxy request->path #f 7654 10 tcp@))
  (current-proxy-servers '(("http" "localhost" 7654)))

  ; Wait for the proxy to start up
  (sleep 1)
  (define proxy-tests
     "All tests for proxy"

      "remote host is proxied"
      (let ([ip
             ;; If we ask for we might get
             ;; redirected to the local version, but if we
             ;; ask for a country specific version we get it
             (get-pure-port (string->url ""))])
         (check-not-false (regexp-match #rx"Google" ip))
         (close-input-port ip))))