-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathStarscreamAdapterTests.swift
34 lines (31 loc) · 1.17 KB
/
StarscreamAdapterTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
import XCTest
@testable import AppSyncRealTimeClient
import Starscream
class StarscreamAdapterTests: AppSyncRealTimeClientTestBase {
func testConnectDisconnect() throws {
let starscreamAdapter = StarscreamAdapter()
let apiKeyAuthInterceptor = APIKeyAuthInterceptor(apiKey)
let request = AppSyncConnectionRequest(url: urlRequest.url!)
let signedRequest = apiKeyAuthInterceptor.interceptConnection(request, for: urlRequest.url!)
urlRequest.url = signedRequest.url
let expectedPerforms = expectation(description: "total performs")
expectedPerforms.expectedFulfillmentCount = 1_000
DispatchQueue.concurrentPerform(iterations: 1_000) { _ in
starscreamAdapter.connect(
urlRequest: urlRequest,
protocols: ["graphql-ws"],
delegate: nil
)
starscreamAdapter.disconnect()
expectedPerforms.fulfill()
}
wait(for: [expectedPerforms], timeout: 1)
XCTAssertFalse(starscreamAdapter.isConnected)
}
}