(use-modules (tests)
             (fibers)
             (unit-test)
             (web uri)
             (web client)
             (web response)
             (knots web-server)
             (knots non-blocking))

(run-fibers-for-tests
 (lambda ()
   (let* ((web-server
           (run-knots-web-server
            (lambda (request)
              (values '((content-type . (text/plain)))
                      "Hello, World!"))
            #:port 0)) ;; Bind to any port
          (port
           (web-server-port web-server))
          (uri
           (build-uri 'http #:host "127.0.0.1" #:port port)))


     (assert-equal
      200
      (response-code
       (http-get
        uri
        #:port (non-blocking-open-socket-for-uri uri)))))))

(display "non-blocking test finished successfully\n")
