Skip to content

Commit

Permalink
Kitura/Kitura#33 Added a test of a graceful close from the client
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuelk committed Dec 21, 2016
1 parent fcdf807 commit 60a811e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Tests/KituraWebSocketTests/BasicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ class BasicTests: XCTestCase {
performServerTest() { expectation in
guard let socket = self.sendUpgradeRequest(toPath: "/wstester", usingKey: self.secWebKey) else { return }

_ = self.checkUpgradeResponse(from: socket, forKey: self.secWebKey, expectation: expectation)
let buffer = self.checkUpgradeResponse(from: socket, forKey: self.secWebKey, expectation: expectation)

_ = self.sendFrame(final: true, withOpcode: self.opcodeClose,
withPayload: self.payload(closeReasonCode: .normal), on: socket)

let (final, opcode, payload, _) = self.parseFrame(using: buffer, position: 0, from: socket)

XCTAssert(final, "Close message wasn't final")
XCTAssertEqual(opcode, self.opcodeClose, "Opcode wasn't close. was \(opcode)")
self.checkCloseReasonCode(payload: payload, expectedReasonCode: .normal)

// Wait a bit for the WebSocketService
usleep(150)

Expand Down

0 comments on commit 60a811e

Please sign in to comment.