Skip to content

Commit

Permalink
Merge pull request #48 from applivery/refactor/migrate-callback-to-as…
Browse files Browse the repository at this point in the history
…ync-await

migrate callback to async await
  • Loading branch information
FranAlarza authored Dec 5, 2024
2 parents 57f6b51 + 75659b8 commit ea197d4
Show file tree
Hide file tree
Showing 99 changed files with 4,515 additions and 3,959 deletions.
28 changes: 16 additions & 12 deletions .swiftpm/xcode/xcshareddata/xcschemes/Applivery.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForTesting = "NO"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
Expand All @@ -21,7 +21,7 @@
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForTesting = "NO"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
Expand All @@ -48,6 +48,20 @@
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "NO"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AppliveryBehaviorTests"
BuildableName = "AppliveryBehaviorTests"
BlueprintName = "AppliveryBehaviorTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand All @@ -66,16 +80,6 @@
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AppliveryBehaviorTests"
BuildableName = "AppliveryBehaviorTests"
BlueprintName = "AppliveryBehaviorTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
110 changes: 0 additions & 110 deletions AppliveryBehaviorTests/Helpers/ConfiguratorMock.swift

This file was deleted.

35 changes: 35 additions & 0 deletions AppliveryBehaviorTests/MockData/ConfigMockData.swift
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"
)
)
}
30 changes: 30 additions & 0 deletions AppliveryBehaviorTests/Mockits/MockAPIClient.swift
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.
9 changes: 7 additions & 2 deletions AppliveryBehaviorTests/Mocks/AppMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit


class AppMock: AppProtocol {

// Inputs
var stubBundleID: String = "NO BUNDLE ID SET"
var stubSDKVersion: String = "NO VERSION SET"
Expand All @@ -30,7 +30,8 @@ class AppMock: AppProtocol {
var spyDownloadClosure: (() -> Void)?
var spyRetryClosure: (() -> Void)?
var spyShowLoadingCalled = false
var spyHideLoadingCalled = false
var spyHideLoadingCalled = false
var spyPresentFeedbackForm = false
var spyLoginView = (called: false, message: "")
var spyLoginCancelClosure: (() -> Void)?
var spyLoginClosure: ((String, String) -> Void)?
Expand Down Expand Up @@ -97,4 +98,8 @@ class AppMock: AppProtocol {
self.spyLoginCancelClosure = cancelHandler
self.spyLoginClosure = loginHandler
}

func presentFeedbackForm() {
self.spyPresentFeedbackForm = true
}
}
7 changes: 4 additions & 3 deletions AppliveryBehaviorTests/Mocks/ConfigPersisterMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ import UIKit
class ConfigPersisterMock: ConfigPersister {

// INPUT
var config: Config?
var config: SDKData?

// OUTPUT
var saveCalled = false

override func getConfig() -> Config? {
override func getConfig() -> SDKData? {
return self.config
}

override func saveConfig(_ config: Config) {
override func saveConfig(_ config: SDKData) {
self.saveCalled = true
self.config = config
}
}
36 changes: 23 additions & 13 deletions AppliveryBehaviorTests/Mocks/ConfigServiceMock.swift
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")
}
}

26 changes: 0 additions & 26 deletions AppliveryBehaviorTests/Mocks/DownloadServiceMock.swift

This file was deleted.

27 changes: 0 additions & 27 deletions AppliveryBehaviorTests/Mocks/FeedbackCoordinatorMock.swift

This file was deleted.

Loading

0 comments on commit ea197d4

Please sign in to comment.