-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local server not responding to requests #4
Comments
Hi @Chandlerdea, I cannot reproduce the bug. Here's the code I wrote import XCTest
import Embassy
import EnvoyAmbassador
class ServerTest: XCTestCase {
let port = 8080
var router: Router!
var eventLoop: EventLoopType!
var server: HTTPServer!
var app: XCUIApplication!
var eventLoopThreadCondition: NSCondition!
var eventLoopThread: NSThread!
func startHTTPServer() {
self.eventLoop = try! SelectorEventLoop(selector: try! KqueueSelector())
self.router = Router()
self.server = HTTPServer(eventLoop: self.eventLoop, app: self.router.app, port: self.port)
try! self.server.start()
self.eventLoopThreadCondition = NSCondition()
self.eventLoopThread = NSThread(target: self, selector: #selector(self.runEventLoop), object: nil)
self.eventLoopThread.start()
}
func stopHTTPServer() {
self.server.stopAndWait()
self.eventLoopThreadCondition.lock()
self.eventLoop.stop()
while self.eventLoop.running {
if !self.eventLoopThreadCondition.waitUntilDate(NSDate().dateByAddingTimeInterval(10)) {
fatalError("Join eventLoopThread timeout")
}
}
}
@objc func runEventLoop() {
self.eventLoop.runForever()
self.eventLoopThreadCondition.lock()
self.eventLoopThreadCondition.signal()
self.eventLoopThreadCondition.unlock()
}
func testServer() {
startHTTPServer()
// run server for ever
let exp = expectationWithDescription("")
waitForExpectationsWithTimeout(999999, handler: nil)
}
} And it works perfectly fine to return a 404 error
Did you try to hold the test case a little while like what I did? let exp = expectationWithDescription("")
waitForExpectationsWithTimeout(999999, handler: nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am able to connect to the local server on port 8080, but it does not respond to requests. Here is what it looks like when I curl:
I used the code from your medium post to setup and tear down the local server:
`private extension UITests {
}`
Let me know if you have any questions that I can answer.
The text was updated successfully, but these errors were encountered: