Skip to content

Commit

Permalink
Updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swhitty committed Oct 24, 2023
1 parent fc1f186 commit 806728f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion FlyingFox/Tests/HTTPServerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ final class HTTPServerTests: XCTestCase {
}
}

func testThrowsError_WhenSocketAlreadyListening() async throws {
let server = HTTPServer.make(port: 42185)
let socket = try await server.makeSocketAndListen()
defer { try! socket.close() }

await AsyncAssertThrowsError(try await server.start(), of: SocketError.self) {
XCTAssertTrue(
$0.errorDescription?.contains("Address already in use") == true
)
}
}

func testRestarts_AfterStopped() async throws {
let server = HTTPServer.make()
try await startServer(server)
Expand Down Expand Up @@ -397,7 +409,7 @@ extension HTTPServer {
timeout: TimeInterval = 15,
logger: Logging? = nil,
handler: HTTPHandler? = nil) -> HTTPServer {
HTTPServer(port: port,
HTTPServer(address: .loopback(port: port),
timeout: timeout,
logger: logger,
handler: handler)
Expand Down

0 comments on commit 806728f

Please sign in to comment.