diff --git a/AmplifyPlugins/Storage/Tests/AWSS3StoragePluginTests/AWSS3StoragePluginTestBase.swift b/AmplifyPlugins/Storage/Tests/AWSS3StoragePluginTests/AWSS3StoragePluginTestBase.swift index 5ed47beb9e..abaaa2534b 100644 --- a/AmplifyPlugins/Storage/Tests/AWSS3StoragePluginTests/AWSS3StoragePluginTestBase.swift +++ b/AmplifyPlugins/Storage/Tests/AWSS3StoragePluginTests/AWSS3StoragePluginTestBase.swift @@ -10,6 +10,7 @@ import Amplify @testable import AWSS3StoragePlugin @testable import AmplifyTestCommon @testable import AWSPluginsTestCommon +import InternalAmplifyCredentials class AWSS3StoragePluginTests: XCTestCase { var storagePlugin: AWSS3StoragePlugin! @@ -33,9 +34,29 @@ class AWSS3StoragePluginTests: XCTestCase { authService = MockAWSAuthService() queue = MockOperationQueue() - storagePlugin.configure(storageService: storageService, + storagePlugin.configure(defaultBucket: testBucket, + storageService: storageService, authService: authService, defaultAccessLevel: defaultAccessLevel, queue: queue) } } + + +extension AWSS3StoragePlugin { + /// Convenience configuration method for testing purposes. Uses "bucket" as defaultBucket + func configure( + storageService: AWSS3StorageServiceBehavior, + authService: AWSAuthCredentialsProviderBehavior, + defaultAccessLevel: StorageAccessLevel, + queue: OperationQueue = OperationQueue() + ) { + configure( + defaultBucket: "bucket", + storageService: storageService, + authService: authService, + defaultAccessLevel: defaultAccessLevel, + queue: queue + ) + } +} diff --git a/AmplifyPlugins/Storage/Tests/AWSS3StoragePluginTests/Support/Internal/AWSS3StorageOperations+StorageServiceProvider.swift b/AmplifyPlugins/Storage/Tests/AWSS3StoragePluginTests/Support/Internal/AWSS3StorageOperations+StorageServiceProvider.swift new file mode 100644 index 0000000000..71931f237a --- /dev/null +++ b/AmplifyPlugins/Storage/Tests/AWSS3StoragePluginTests/Support/Internal/AWSS3StorageOperations+StorageServiceProvider.swift @@ -0,0 +1,99 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +@testable import Amplify +@testable import AWSPluginsCore +@testable import AWSS3StoragePlugin +import Foundation + +extension AWSS3StorageDownloadFileOperation { + convenience init( + _ request: StorageDownloadFileRequest, + storageConfiguration: AWSS3StoragePluginConfiguration, + storageService: AWSS3StorageServiceBehavior, + authService: AWSAuthServiceBehavior, + progressListener: InProcessListener? = nil, + resultListener: ResultListener? = nil + ) { + self.init( + request, + storageConfiguration: storageConfiguration, + storageServiceProvider: { + return storageService + }, + authService: authService, + progressListener: progressListener, + resultListener: resultListener + ) + } +} + +extension AWSS3StorageDownloadDataOperation { + convenience init( + _ request: StorageDownloadDataRequest, + storageConfiguration: AWSS3StoragePluginConfiguration, + storageService: AWSS3StorageServiceBehavior, + authService: AWSAuthServiceBehavior, + progressListener: InProcessListener? = nil, + resultListener: ResultListener? = nil + ) { + self.init( + request, + storageConfiguration: storageConfiguration, + storageServiceProvider: { + return storageService + }, + authService: authService, + progressListener: progressListener, + resultListener: resultListener + ) + } +} + +extension AWSS3StorageUploadDataOperation { + convenience init( + _ request: StorageUploadDataRequest, + storageConfiguration: AWSS3StoragePluginConfiguration, + storageService: AWSS3StorageServiceBehavior, + authService: AWSAuthServiceBehavior, + progressListener: InProcessListener? = nil, + resultListener: ResultListener? = nil + ) { + self.init( + request, + storageConfiguration: storageConfiguration, + storageServiceProvider: { + return storageService + }, + authService: authService, + progressListener: progressListener, + resultListener: resultListener + ) + } +} + +extension AWSS3StorageUploadFileOperation { + convenience init( + _ request: StorageUploadFileRequest, + storageConfiguration: AWSS3StoragePluginConfiguration, + storageService: AWSS3StorageServiceBehavior, + authService: AWSAuthServiceBehavior, + progressListener: InProcessListener? = nil, + resultListener: ResultListener? = nil + ) { + self.init( + request, + storageConfiguration: storageConfiguration, + storageServiceProvider: { + return storageService + }, + authService: authService, + progressListener: progressListener, + resultListener: resultListener + ) + } +}