Skip to content

Commit

Permalink
chore: resolve swiftformat errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
phantumcode committed Sep 3, 2024
1 parent ca6c65a commit 78bd9ff
Show file tree
Hide file tree
Showing 306 changed files with 1,572 additions and 1,184 deletions.
2 changes: 1 addition & 1 deletion AmplifyTestApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import UIKit

@UIApplicationMain
@main
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
Expand Down
6 changes: 4 additions & 2 deletions AmplifyTestCommon/Helpers/AmplifyAssertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import XCTest

public func XCTAssertThrowFatalError(_ expression: @escaping () -> Void,
file: StaticString = #file,
line: UInt = #line) throws {
line: UInt = #line) throws
{
#if (os(iOS) || os(macOS)) && (arch(arm64) || arch(x86_64))
var reached = false
let exception = catchBadInstruction {
Expand All @@ -28,7 +29,8 @@ public func XCTAssertThrowFatalError(_ expression: @escaping () -> Void,

public func XCTAssertNoThrowFatalError(_ expression: @escaping () -> Void,
file: StaticString = #file,
line: UInt = #line) throws {
line: UInt = #line) throws
{
#if (os(iOS) || os(macOS)) && (arch(arm64) || arch(x86_64))
var reached = false
let exception = catchBadInstruction {
Expand Down
2 changes: 1 addition & 1 deletion AmplifyTestCommon/Helpers/AuthSignInHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Amplify

public typealias CompletionType = (Bool, AuthError?) -> Void

public struct AuthSignInHelper {
public enum AuthSignInHelper {

public static func signUpUser(username: String, password: String, email: String) async throws -> AuthSignUpResult {
let options = AuthSignUpRequest.Options(userAttributes: [AuthUserAttribute(.email, value: email)])
Expand Down
5 changes: 3 additions & 2 deletions AmplifyTestCommon/Helpers/HubListenerTestUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Amplify
import Foundation

struct HubListenerTestUtilities {
enum HubListenerTestUtilities {

/// Blocks current thread until the listener with `token` is attached to the plugin. Returns `true` if the listener
/// becomes present before the `timeout` expires, `false` otherwise.
Expand All @@ -21,7 +21,8 @@ struct HubListenerTestUtilities {
plugin: HubCategoryPlugin? = nil,
timeout: TimeInterval,
file: StaticString = #file,
line: UInt = #line) async throws -> Bool {
line: UInt = #line) async throws -> Bool
{

let plugin = try plugin ?? Amplify.Hub.getPlugin(for: AWSHubPlugin.key)

Expand Down
2 changes: 1 addition & 1 deletion AmplifyTestCommon/Helpers/TypeRegistry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TypeRegistry {
hasher.combine(ObjectIdentifier(type))
}

static func ==(lhs: TypeRegistry.Key, rhs: TypeRegistry.Key) -> Bool {
static func == (lhs: TypeRegistry.Key, rhs: TypeRegistry.Key) -> Bool {
lhs.type == rhs.type
}
}
Expand Down
44 changes: 24 additions & 20 deletions AmplifyTestCommon/Mocks/MockAPICategoryPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import Foundation
class MockAPICategoryPlugin: MessageReporter,
APICategoryPlugin,
APICategoryReachabilityBehavior,
APICategoryGraphQLBehavior {
APICategoryGraphQLBehavior
{

var authProviderFactory: APIAuthProviderFactory?

Expand Down Expand Up @@ -91,11 +92,11 @@ class MockAPICategoryPlugin: MessageReporter,
variables: request.variables,
responseType: request.responseType,
options: requestOptions)

let taskRunner = MockAWSGraphQLSubscriptionTaskRunner(request: request)
return taskRunner.sequence
}

public func reachabilityPublisher(for apiName: String?) -> AnyPublisher<ReachabilityUpdate, Never>? {
reachabilityPublisher()
}
Expand All @@ -121,7 +122,7 @@ class MockAPICategoryPlugin: MessageReporter,
let operation = MockAPIOperation(request: operationRequest)
return operation
}

func get(request: RESTRequest) async throws -> RESTTask.Success {
notify("get")
return Data()
Expand All @@ -138,7 +139,7 @@ class MockAPICategoryPlugin: MessageReporter,
let operation = MockAPIOperation(request: request)
return operation
}

func put(request: RESTRequest) async throws -> RESTTask.Success {
notify("put")
let request = RESTOperationRequest(apiName: request.apiName,
Expand Down Expand Up @@ -176,7 +177,7 @@ class MockAPICategoryPlugin: MessageReporter,
let taskAdapter = AmplifyOperationTaskAdapter(operation: operation)
return try await taskAdapter.value
}

func delete(request: RESTRequest, listener: RESTOperation.ResultListener?) -> RESTOperation {
notify("delete")
let request = RESTOperationRequest(apiName: request.apiName,
Expand All @@ -201,7 +202,7 @@ class MockAPICategoryPlugin: MessageReporter,
let taskAdapter = AmplifyOperationTaskAdapter(operation: operation)
return try await taskAdapter.value
}

func patch(request: RESTRequest, listener: RESTOperation.ResultListener?) -> RESTOperation {
notify("patch")
let request = RESTOperationRequest(apiName: request.apiName,
Expand All @@ -213,7 +214,7 @@ class MockAPICategoryPlugin: MessageReporter,
let operation = MockAPIOperation(request: request)
return operation
}

func patch(request: RESTRequest) async throws -> RESTTask.Success {
notify("patch")
let request = RESTOperationRequest(apiName: request.apiName,
Expand All @@ -238,7 +239,7 @@ class MockAPICategoryPlugin: MessageReporter,
let operation = MockAPIOperation(request: request)
return operation
}

func head(request: RESTRequest) async throws -> RESTTask.Success {
notify("head")
let request = RESTOperationRequest(apiName: request.apiName,
Expand All @@ -251,7 +252,7 @@ class MockAPICategoryPlugin: MessageReporter,
let taskAdapter = AmplifyOperationTaskAdapter(operation: operation)
return try await taskAdapter.value
}


func add(interceptor: URLRequestInterceptor, for apiName: String) {
notify("addInterceptor")
Expand All @@ -260,7 +261,7 @@ class MockAPICategoryPlugin: MessageReporter,
// MARK: - APICategoryAuthProviderFactoryBehavior

func apiAuthProviderFactory() -> APIAuthProviderFactory {
if let authProviderFactory = authProviderFactory {
if let authProviderFactory {
return authProviderFactory
} else {
return APIAuthProviderFactory()
Expand All @@ -282,7 +283,8 @@ class MockGraphQLOperation<R: Decodable>: GraphQLOperation<R> {
}

init(request: Request,
responseType: R.Type) {
responseType: R.Type)
{
super.init(categoryType: .api,
eventName: HubPayload.EventName.API.mutate,
request: request)
Expand All @@ -298,7 +300,8 @@ class MockSubscriptionGraphQLOperation<R: Decodable>: GraphQLSubscriptionOperati
}

init(request: Request,
responseType: R.Type) {
responseType: R.Type)
{
super.init(categoryType: .api,
eventName: HubPayload.EventName.API.subscribe,
request: request)
Expand All @@ -324,7 +327,8 @@ class MockAPIAuthProviderFactory: APIAuthProviderFactory {
let functionProvider: AmplifyFunctionAuthProvider?

init(oidcProvider: AmplifyOIDCAuthProvider? = nil,
functionProvider: AmplifyFunctionAuthProvider? = nil) {
functionProvider: AmplifyFunctionAuthProvider? = nil)
{
self.oidcProvider = oidcProvider
self.functionProvider = functionProvider
}
Expand All @@ -340,7 +344,7 @@ class MockAPIAuthProviderFactory: APIAuthProviderFactory {

class MockOIDCAuthProvider: AmplifyOIDCAuthProvider {
var result: Result<AuthToken, Error>?

func getLatestAuthToken() async throws -> String {
if case let .success(token) = result {
return token
Expand All @@ -352,7 +356,7 @@ class MockOIDCAuthProvider: AmplifyOIDCAuthProvider {

class MockFunctionAuthProvider: AmplifyFunctionAuthProvider {
var result: Result<AuthToken, Error>?

func getLatestAuthToken() async throws -> String {
if case let .success(token) = result {
return token
Expand All @@ -363,17 +367,17 @@ class MockFunctionAuthProvider: AmplifyFunctionAuthProvider {
}

class MockAWSGraphQLSubscriptionTaskRunner<R: Decodable>: InternalTaskRunner, InternalTaskAsyncThrowingSequence, InternalTaskThrowingChannel {

public typealias Request = GraphQLOperationRequest<R>
public typealias InProcess = GraphQLSubscriptionEvent<R>
public var request: GraphQLOperationRequest<R>
public var context = InternalTaskAsyncThrowingSequenceContext<GraphQLSubscriptionEvent<R>>()
func run() async throws {

}

init(request: GraphQLOperationRequest<R>) {
self.request = request
}

}
32 changes: 21 additions & 11 deletions AmplifyTestCommon/Mocks/MockAuthCategoryPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//

import Foundation
import Amplify
import Foundation

class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin {

Expand All @@ -16,7 +16,8 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin {

func signIn(username: String,
password: String,
options: AuthSignInRequest.Options?) async throws -> AuthSignInResult {
options: AuthSignInRequest.Options?) async throws -> AuthSignInResult
{
fatalError()
}

Expand All @@ -26,7 +27,8 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin {

public func confirmSignUp(for username: String,
confirmationCode: String,
options: AuthConfirmSignUpRequest.Options? = nil) async throws -> AuthSignUpResult {
options: AuthConfirmSignUpRequest.Options? = nil) async throws -> AuthSignUpResult
{
fatalError()
}

Expand All @@ -36,25 +38,29 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin {

public func signIn(username: String? = nil,
password: String? = nil,
options: AuthSignInRequest.Options? = nil) async throws -> AuthSignInResult {
options: AuthSignInRequest.Options? = nil) async throws -> AuthSignInResult
{
fatalError()
}

#if os(iOS) || os(macOS)
public func signInWithWebUI(presentationAnchor: AuthUIPresentationAnchor? = nil,
options: AuthWebUISignInRequest.Options? = nil) async throws -> AuthSignInResult {
options: AuthWebUISignInRequest.Options? = nil) async throws -> AuthSignInResult
{
fatalError()
}

public func signInWithWebUI(for authProvider: AuthProvider,
presentationAnchor: AuthUIPresentationAnchor? = nil,
options: AuthWebUISignInRequest.Options? = nil) async throws -> AuthSignInResult {
options: AuthWebUISignInRequest.Options? = nil) async throws -> AuthSignInResult
{
fatalError()
}
#endif

public func confirmSignIn(challengeResponse: String,
options: AuthConfirmSignInRequest.Options? = nil) async throws -> AuthSignInResult {
options: AuthConfirmSignInRequest.Options? = nil) async throws -> AuthSignInResult
{
fatalError()
}

Expand All @@ -77,7 +83,8 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin {
public func confirmResetPassword(for username: String,
with newPassword: String,
confirmationCode: String,
options: AuthConfirmResetPasswordRequest.Options? = nil) async throws {
options: AuthConfirmResetPasswordRequest.Options? = nil) async throws
{
fatalError()
}

Expand All @@ -94,7 +101,8 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin {
}

public func resendConfirmationCode(forUserAttributeKey userAttributeKey: AuthUserAttributeKey, options: AuthAttributeResendConfirmationCodeRequest.Options? = nil)
async throws -> AuthCodeDeliveryDetails {
async throws -> AuthCodeDeliveryDetails
{
fatalError()
}

Expand All @@ -118,13 +126,15 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin {

public func confirm(userAttribute: AuthUserAttributeKey,
confirmationCode: String,
options: AuthConfirmUserAttributeRequest.Options? = nil) async throws {
options: AuthConfirmUserAttributeRequest.Options? = nil) async throws
{
fatalError()
}

public func update(oldPassword: String,
to newPassword: String,
options: AuthChangePasswordRequest.Options? = nil) async throws {
options: AuthChangePasswordRequest.Options? = nil) async throws
{
notify("changePassword")

}
Expand Down
4 changes: 2 additions & 2 deletions AmplifyTestCommon/Mocks/MockCredentialsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
// SPDX-License-Identifier: Apache-2.0
//

import AWSPluginsCore
import AWSClientRuntime
import AWSPluginsCore
import Foundation

class MockCredentialsProvider: AWSClientRuntime.CredentialsProviding {
func getCredentials() async throws -> AWSClientRuntime.AWSCredentials {
return AWSCredentials(
accessKey: "accessKey",
secret: "secret",
expirationTimeout: Date().addingTimeInterval(1000)
expirationTimeout: Date().addingTimeInterval(1_000)
)
}
}
Loading

0 comments on commit 78bd9ff

Please sign in to comment.