Skip to content

Commit 797711a

Browse files
committed
fix build errors in API plugin unit tests
1 parent 8859896 commit 797711a

File tree

8 files changed

+30
-10
lines changed

8 files changed

+30
-10
lines changed

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Interceptor/SubscriptionInterceptor/APIKeyAuthInterceptorTests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import XCTest
1010
import Amplify
1111
@testable import AWSAPIPlugin
12+
@testable @_spi(AppSyncRTC) import AmplifyNetwork
1213

1314
class APIKeyAuthInterceptorTests: XCTestCase {
1415

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Interceptor/SubscriptionInterceptor/CognitoAuthInterceptorTests.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import XCTest
1010
import Amplify
1111
@testable import AWSAPIPlugin
12-
@testable @_spi(WebSocket) import AWSPluginsCore
12+
@testable import AWSPluginsCore
13+
@testable @_spi(WebSocket) @_spi(AppSyncRTC) import AmplifyNetwork
1314

1415
class CognitoAuthInterceptorTests: XCTestCase {
1516

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Mocks/MockSubscription.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import Foundation
1010
import Amplify
1111
import Combine
1212
@testable import AWSAPIPlugin
13-
@_spi(WebSocket) import AWSPluginsCore
13+
@testable import AWSPluginsCore
14+
@testable @_spi(WebSocket) @_spi(AppSyncRTC) import AmplifyNetwork
1415

1516
struct MockSubscriptionConnectionFactory: AppSyncRealTimeClientFactoryProtocol {
1617

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Operation/GraphQLSubscribeCombineTests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import XCTest
1111
import Amplify
1212
@testable import AmplifyTestCommon
1313
@testable import AWSAPIPlugin
14+
@testable @_spi(AppSyncRTC) import AmplifyNetwork
1415
@_implementationOnly import AmplifyAsyncTesting
1516

1617
class GraphQLSubscribeCombineTests: OperationTestBase {

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Operation/GraphQLSubscribeTaskTests.swift

+23-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import XCTest
1111
import Amplify
1212
@testable import AmplifyTestCommon
1313
@testable import AWSAPIPlugin
14+
@testable @_spi(AppSyncRTC) import AmplifyNetwork
1415
@_implementationOnly import AmplifyAsyncTesting
1516

1617
class GraphQLSubscribeTasksTests: OperationTestBase {
@@ -130,7 +131,11 @@ class GraphQLSubscribeTasksTests: OperationTestBase {
130131
await fulfillment(of: [onSubscribeInvoked], timeout: 0.05)
131132

132133
try await MockAppSyncRealTimeClient.waitForSubscirbing()
133-
mockAppSyncRealTimeClient?.triggerEvent(.error([AppSyncRealTimeRequest.Error.limitExceeded]))
134+
mockAppSyncRealTimeClient?.triggerEvent(.error([
135+
"errors": [
136+
"errorType": "LimitExceededError"
137+
]
138+
]))
134139
expectedCompletionFailureError = APIError.operationError("", "", AppSyncRealTimeRequest.Error.limitExceeded)
135140
await waitForSubscriptionExpectations()
136141
}
@@ -145,18 +150,21 @@ class GraphQLSubscribeTasksTests: OperationTestBase {
145150
try await subscribe()
146151
await fulfillment(of: [onSubscribeInvoked], timeout: 0.05)
147152

148-
let unauthorizedError = GraphQLError(message: "", extensions: ["errorType": "Unauthorized"])
149153
try await MockAppSyncRealTimeClient.waitForSubscirbing()
150-
mockAppSyncRealTimeClient?.triggerEvent(.error([unauthorizedError]))
154+
mockAppSyncRealTimeClient?.triggerEvent(.error([
155+
"errors": [
156+
"errorType": "Unauthorized"
157+
]
158+
]))
151159
expectedCompletionFailureError = APIError.operationError(
152160
"Subscription item event failed with error: Unauthorized",
153161
"",
154-
GraphQLResponseError<JSONValue>.error([unauthorizedError])
162+
AppSyncRealTimeRequest.Error.unauthorized
155163
)
156164
await waitForSubscriptionExpectations()
157165
}
158166

159-
func testConnectionErrorWithAppSyncConnectionError() async throws {
167+
func testConnectionErrorWithOtherAppSyncConnectionError() async throws {
160168
receivedCompletionSuccess.isInverted = true
161169
receivedStateValueConnected.isInverted = true
162170
receivedStateValueDisconnected.isInverted = true
@@ -167,8 +175,16 @@ class GraphQLSubscribeTasksTests: OperationTestBase {
167175
await fulfillment(of: [onSubscribeInvoked], timeout: 0.05)
168176

169177
try await MockAppSyncRealTimeClient.waitForSubscirbing()
170-
mockAppSyncRealTimeClient?.triggerEvent(.error([URLError(URLError.Code(rawValue: 400))]))
171-
expectedCompletionFailureError = APIError.operationError("", "", URLError(URLError.Code(rawValue: 400)))
178+
mockAppSyncRealTimeClient?.triggerEvent(.error([
179+
"errors": [
180+
"message": "other error"
181+
]
182+
]))
183+
expectedCompletionFailureError = APIError.operationError(
184+
"Subscription item event failed with error",
185+
"",
186+
GraphQLResponseError<JSONValue>.error([GraphQLError(message: "other error")])
187+
)
172188
await waitForSubscriptionExpectations()
173189
}
174190

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Operation/GraphQLSubscribeTests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import XCTest
99
@testable import Amplify
1010
@testable import AmplifyTestCommon
1111
@testable import AWSAPIPlugin
12+
@testable @_spi(AppSyncRTC) import AmplifyNetwork
1213

1314
class GraphQLSubscribeTests: OperationTestBase {
1415

AmplifyPlugins/API/Tests/AWSAPIPluginTests/AppSyncRealTimeClient/AppSyncRealTimeClientTests.swift renamed to AmplifyPlugins/Internal/Tests/NetworkTests/AppSyncRealTimeClient/AppSyncRealTimeClientTests.swift

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import XCTest
1010
import Combine
1111
import Amplify
12-
@_spi(WebSocket) import AWSPluginsCore
1312
@testable import AWSAPIPlugin
1413

1514
class AppSyncRealTimeClientTests: XCTestCase {

0 commit comments

Comments
 (0)