Skip to content

Commit

Permalink
fix build errors in API plugin unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
5d committed Mar 22, 2024
1 parent 8859896 commit 797711a
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import XCTest
import Amplify
@testable import AWSAPIPlugin
@testable @_spi(AppSyncRTC) import AmplifyNetwork

class APIKeyAuthInterceptorTests: XCTestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import XCTest
import Amplify
@testable import AWSAPIPlugin
@testable @_spi(WebSocket) import AWSPluginsCore
@testable import AWSPluginsCore
@testable @_spi(WebSocket) @_spi(AppSyncRTC) import AmplifyNetwork

class CognitoAuthInterceptorTests: XCTestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Foundation
import Amplify
import Combine
@testable import AWSAPIPlugin
@_spi(WebSocket) import AWSPluginsCore
@testable import AWSPluginsCore
@testable @_spi(WebSocket) @_spi(AppSyncRTC) import AmplifyNetwork

struct MockSubscriptionConnectionFactory: AppSyncRealTimeClientFactoryProtocol {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import XCTest
import Amplify
@testable import AmplifyTestCommon
@testable import AWSAPIPlugin
@testable @_spi(AppSyncRTC) import AmplifyNetwork
@_implementationOnly import AmplifyAsyncTesting

class GraphQLSubscribeCombineTests: OperationTestBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import XCTest
import Amplify
@testable import AmplifyTestCommon
@testable import AWSAPIPlugin
@testable @_spi(AppSyncRTC) import AmplifyNetwork
@_implementationOnly import AmplifyAsyncTesting

class GraphQLSubscribeTasksTests: OperationTestBase {
Expand Down Expand Up @@ -130,7 +131,11 @@ class GraphQLSubscribeTasksTests: OperationTestBase {
await fulfillment(of: [onSubscribeInvoked], timeout: 0.05)

try await MockAppSyncRealTimeClient.waitForSubscirbing()
mockAppSyncRealTimeClient?.triggerEvent(.error([AppSyncRealTimeRequest.Error.limitExceeded]))
mockAppSyncRealTimeClient?.triggerEvent(.error([
"errors": [
"errorType": "LimitExceededError"
]
]))
expectedCompletionFailureError = APIError.operationError("", "", AppSyncRealTimeRequest.Error.limitExceeded)
await waitForSubscriptionExpectations()
}
Expand All @@ -145,18 +150,21 @@ class GraphQLSubscribeTasksTests: OperationTestBase {
try await subscribe()
await fulfillment(of: [onSubscribeInvoked], timeout: 0.05)

let unauthorizedError = GraphQLError(message: "", extensions: ["errorType": "Unauthorized"])
try await MockAppSyncRealTimeClient.waitForSubscirbing()
mockAppSyncRealTimeClient?.triggerEvent(.error([unauthorizedError]))
mockAppSyncRealTimeClient?.triggerEvent(.error([
"errors": [
"errorType": "Unauthorized"
]
]))
expectedCompletionFailureError = APIError.operationError(
"Subscription item event failed with error: Unauthorized",
"",
GraphQLResponseError<JSONValue>.error([unauthorizedError])
AppSyncRealTimeRequest.Error.unauthorized
)
await waitForSubscriptionExpectations()
}

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

try await MockAppSyncRealTimeClient.waitForSubscirbing()
mockAppSyncRealTimeClient?.triggerEvent(.error([URLError(URLError.Code(rawValue: 400))]))
expectedCompletionFailureError = APIError.operationError("", "", URLError(URLError.Code(rawValue: 400)))
mockAppSyncRealTimeClient?.triggerEvent(.error([
"errors": [
"message": "other error"
]
]))
expectedCompletionFailureError = APIError.operationError(
"Subscription item event failed with error",
"",
GraphQLResponseError<JSONValue>.error([GraphQLError(message: "other error")])
)
await waitForSubscriptionExpectations()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import XCTest
@testable import Amplify
@testable import AmplifyTestCommon
@testable import AWSAPIPlugin
@testable @_spi(AppSyncRTC) import AmplifyNetwork

class GraphQLSubscribeTests: OperationTestBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import XCTest
import Combine
import Amplify
@_spi(WebSocket) import AWSPluginsCore
@testable import AWSAPIPlugin

class AppSyncRealTimeClientTests: XCTestCase {
Expand Down

0 comments on commit 797711a

Please sign in to comment.