-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from applivery/refactor/migrate-callback-to-as…
…ync-await migrate callback to async await
- Loading branch information
Showing
99 changed files
with
4,515 additions
and
3,959 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// ConfigMockData.swift | ||
// Applivery | ||
// | ||
// Created by Fran Alarza on 5/12/24. | ||
// | ||
|
||
import Foundation | ||
@testable import Applivery | ||
|
||
struct ConfigMockData { | ||
|
||
static let config = Config( | ||
status: true, | ||
data: ConfigData( | ||
sdk: SDK( | ||
ios: SDKData( | ||
minVersion: "1.0", | ||
forceUpdate: false, | ||
lastBuildId: "build123", | ||
mustUpdateMsg: nil, | ||
ota: true, | ||
lastBuildVersion: "1.0.1", | ||
updateMsg: "Update available", | ||
forceAuth: false | ||
) | ||
), | ||
id: "configId", | ||
slug: "configSlug", | ||
oss: ["iOS"], | ||
name: "TestConfig", | ||
description: "This is a test config" | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// MockAPIClient.swift | ||
// Applivery | ||
// | ||
// Created by Fran Alarza on 3/12/24. | ||
// | ||
|
||
import Foundation | ||
@testable import Applivery | ||
|
||
class MockAPIClient: APIClientProtocol { | ||
var fetchHandler: ((Endpoint) async throws -> Any)? | ||
var uploadVideoHandler: ((URL, URL) async throws -> Void)? | ||
|
||
func fetch<T: Decodable>(endpoint: Endpoint) async throws -> T { | ||
if let result = try await fetchHandler?(endpoint) as? T { | ||
return result | ||
} else { | ||
throw APIError.invalidResponse | ||
} | ||
} | ||
|
||
func uploadVideo(localFileURL: URL, to destinationURL: URL) async throws { | ||
if let handler = uploadVideoHandler { | ||
try await handler(localFileURL, destinationURL) | ||
} else { | ||
print("Mock upload successful") | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
// | ||
// ConfigServiceMock.swift | ||
// AppliverySDK | ||
// Applivery | ||
// | ||
// Created by Alejandro Jiménez on 6/10/15. | ||
// Copyright © 2015 Applivery S.L. All rights reserved. | ||
// Created by Fran Alarza on 5/12/24. | ||
// | ||
|
||
import UIKit | ||
import Foundation | ||
@testable import Applivery | ||
|
||
class ConfigServiceMock: ConfigService { | ||
|
||
var success: Bool! | ||
var config: Config! | ||
var error: NSError! | ||
|
||
override func fetchConfig(_ completionHandler: @escaping (_ success: Bool, _ config: Config?, _ error: NSError?) -> Void) { | ||
completionHandler(self.success, self.config, self.error) | ||
} | ||
final class ConfigServiceMock: ConfigServiceProtocol { | ||
|
||
var updateConfigResponse: UpdateConfigResponse? | ||
var currentConfigResponse: UpdateConfigResponse? | ||
|
||
func updateConfig() async throws -> UpdateConfigResponse { | ||
if let response = updateConfigResponse { | ||
return response | ||
} else { | ||
throw NSError(domain: "MockConfigServiceError", code: 1, userInfo: [NSLocalizedDescriptionKey: "No response configured for updateConfig"]) | ||
} | ||
} | ||
|
||
func getCurrentConfig() -> UpdateConfigResponse { | ||
if let response = currentConfigResponse { | ||
return response | ||
} | ||
fatalError("No response configured for getCurrentConfig") | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
AppliveryBehaviorTests/Mocks/FeedbackCoordinatorMock.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.