Skip to content

Commit

Permalink
fix(internal-pinpoint-tests): update tests for new sdk version (#3275)
Browse files Browse the repository at this point in the history
  • Loading branch information
atierian authored Oct 4, 2023
1 parent eacdffd commit 958da02
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation
actor MockEndpointClient: EndpointClientBehaviour {
let pinpointClient: PinpointClientProtocol = MockPinpointClient()

class MockCredentialsProvider: CredentialsProvider {
class MockCredentialsProvider: CredentialsProviding {
func getCredentials() async throws -> AWSCredentials {
return AWSCredentials(accessKey: "", secret: "", expirationTimeout: Date().addingTimeInterval(1000))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ import AWSPinpoint
import Foundation

class MockPinpointClient: PinpointClientProtocol {
func getJourneyRunExecutionActivityMetrics(input: GetJourneyRunExecutionActivityMetricsInput) async throws -> GetJourneyRunExecutionActivityMetricsOutputResponse {
fatalError("Not supported")
}

func getJourneyRunExecutionMetrics(input: GetJourneyRunExecutionMetricsInput) async throws -> GetJourneyRunExecutionMetricsOutputResponse {
fatalError("Not supported")
}

func getJourneyRuns(input: GetJourneyRunsInput) async throws -> GetJourneyRunsOutputResponse {
fatalError("Not supported")
}

func createApp(input: CreateAppInput) async throws -> CreateAppOutputResponse {
fatalError("Not supported")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ class PinpointRequestsRegistryTests: XCTestCase {

private func createSdkRequest(for api: PinpointRequestsRegistry.API?) throws -> SdkHttpRequest {
let apiPath = api?.rawValue ?? "otherApi"
let endpoint = try Endpoint(urlString: "https://host:42/path/\(apiPath)/suffix")
let headers = [
"User-Agent": "mocked_user_agent"
]
return SdkHttpRequest(method: .put,
endpoint: endpoint,
headers: .init(headers))
let endpoint = try Endpoint(
urlString: "https://host:42/path/\(apiPath)/suffix",
headers: .init(["User-Agent": "mocked_user_agent"])
)
return SdkHttpRequest(
method: .put,
endpoint: endpoint
)
}
}

Expand All @@ -88,35 +89,6 @@ private extension HttpClientEngine {
}
}

private class MockSDKRuntimeConfiguration: SDKRuntimeConfiguration {
var encoder: ClientRuntime.RequestEncoder?
var decoder: ClientRuntime.ResponseDecoder?
var httpClientConfiguration: ClientRuntime.HttpClientConfiguration
var idempotencyTokenGenerator: ClientRuntime.IdempotencyTokenGenerator
var clientLogMode: ClientRuntime.ClientLogMode
var partitionID: String?

let logger: LogAgent
let retryer: SDKRetryer
var endpoint: String? = nil
private let mockedHttpClientEngine : HttpClientEngine

init(httpClientEngine: HttpClientEngine) throws {
let defaultSDKRuntimeConfig = try DefaultSDKRuntimeConfiguration("MockSDKRuntimeConfiguration")
httpClientConfiguration = defaultSDKRuntimeConfig.httpClientConfiguration
idempotencyTokenGenerator = defaultSDKRuntimeConfig.idempotencyTokenGenerator
clientLogMode = defaultSDKRuntimeConfig.clientLogMode

logger = MockLogAgent()
retryer = try SDKRetryer(options: RetryOptions(jitterMode: .default))
mockedHttpClientEngine = httpClientEngine
}

var httpClientEngine: HttpClientEngine {
mockedHttpClientEngine
}
}

private class MockHttpClientEngine: HttpClientEngine {
var executeCount = 0
func execute(request: SdkHttpRequest) async throws -> HttpResponse {
Expand Down

0 comments on commit 958da02

Please sign in to comment.