Skip to content

Commit

Permalink
test: Fixing existing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ruisebas committed Aug 14, 2024
1 parent 5513b43 commit 90c4f06
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Amplify
@testable import AWSS3StoragePlugin
@testable import AmplifyTestCommon
@testable import AWSPluginsTestCommon
import InternalAmplifyCredentials

class AWSS3StoragePluginTests: XCTestCase {
var storagePlugin: AWSS3StoragePlugin!
Expand All @@ -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
)
}
}
Original file line number Diff line number Diff line change
@@ -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
)
}
}

0 comments on commit 90c4f06

Please sign in to comment.