-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathAppSyncRealTimeClientTestBase.swift
50 lines (42 loc) · 1.38 KB
/
AppSyncRealTimeClientTestBase.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
import XCTest
@testable import AppSyncRealTimeClient
class AppSyncRealTimeClientTestBase: XCTestCase {
var urlRequest: URLRequest!
var apiKey: String!
let requestString = """
subscription onCreate {
onCreateTodo{
id
description
name
}
}
"""
override func setUp() {
AppSyncRealTimeClient.logLevel = .debug
do {
let json = try ConfigurationHelper.retrieve(forResource: "amplifyconfiguration")
if let data = json as? [String: Any],
let api = data["api"] as? [String: Any],
let plugins = api["plugins"] as? [String: Any],
let awsAPIPlugin = plugins["awsAPIPlugin"] as? [String: Any],
let apiNameOptional = awsAPIPlugin.first,
let apiName = apiNameOptional.value as? [String: Any],
let endpoint = apiName["endpoint"] as? String,
let apiKey = apiName["apiKey"] as? String {
urlRequest = URLRequest(url: URL(string: endpoint)!)
self.apiKey = apiKey
} else {
throw "Could not retrieve endpoint"
}
} catch {
print("Error \(error)")
}
}
}