@@ -11,6 +11,7 @@ import XCTest
11
11
import Amplify
12
12
@testable import AmplifyTestCommon
13
13
@testable import AWSAPIPlugin
14
+ @testable @_spi ( AppSyncRTC) import AmplifyNetwork
14
15
@_implementationOnly import AmplifyAsyncTesting
15
16
16
17
class GraphQLSubscribeTasksTests : OperationTestBase {
@@ -130,7 +131,11 @@ class GraphQLSubscribeTasksTests: OperationTestBase {
130
131
await fulfillment ( of: [ onSubscribeInvoked] , timeout: 0.05 )
131
132
132
133
try await MockAppSyncRealTimeClient . waitForSubscirbing ( )
133
- mockAppSyncRealTimeClient? . triggerEvent ( . error( [ AppSyncRealTimeRequest . Error. limitExceeded] ) )
134
+ mockAppSyncRealTimeClient? . triggerEvent ( . error( [
135
+ " errors " : [
136
+ " errorType " : " LimitExceededError "
137
+ ]
138
+ ] ) )
134
139
expectedCompletionFailureError = APIError . operationError ( " " , " " , AppSyncRealTimeRequest . Error. limitExceeded)
135
140
await waitForSubscriptionExpectations ( )
136
141
}
@@ -145,18 +150,21 @@ class GraphQLSubscribeTasksTests: OperationTestBase {
145
150
try await subscribe ( )
146
151
await fulfillment ( of: [ onSubscribeInvoked] , timeout: 0.05 )
147
152
148
- let unauthorizedError = GraphQLError ( message: " " , extensions: [ " errorType " : " Unauthorized " ] )
149
153
try await MockAppSyncRealTimeClient . waitForSubscirbing ( )
150
- mockAppSyncRealTimeClient? . triggerEvent ( . error( [ unauthorizedError] ) )
154
+ mockAppSyncRealTimeClient? . triggerEvent ( . error( [
155
+ " errors " : [
156
+ " errorType " : " Unauthorized "
157
+ ]
158
+ ] ) )
151
159
expectedCompletionFailureError = APIError . operationError (
152
160
" Subscription item event failed with error: Unauthorized " ,
153
161
" " ,
154
- GraphQLResponseError < JSONValue > . error ( [ unauthorizedError ] )
162
+ AppSyncRealTimeRequest . Error . unauthorized
155
163
)
156
164
await waitForSubscriptionExpectations ( )
157
165
}
158
166
159
- func testConnectionErrorWithAppSyncConnectionError ( ) async throws {
167
+ func testConnectionErrorWithOtherAppSyncConnectionError ( ) async throws {
160
168
receivedCompletionSuccess. isInverted = true
161
169
receivedStateValueConnected. isInverted = true
162
170
receivedStateValueDisconnected. isInverted = true
@@ -167,8 +175,16 @@ class GraphQLSubscribeTasksTests: OperationTestBase {
167
175
await fulfillment ( of: [ onSubscribeInvoked] , timeout: 0.05 )
168
176
169
177
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
+ )
172
188
await waitForSubscriptionExpectations ( )
173
189
}
174
190
0 commit comments