Skip to content

Commit

Permalink
Add mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
swiftyfinch committed Nov 27, 2023
1 parent 99de828 commit c1727b7
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Tests/FoundationTests/Mocks/IFileContentHasherMock.generated.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Generated using Sourcery 2.1.1 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

// swiftlint:disable all

import Foundation
@testable import RugbyFoundation

final class IFileContentHasherMock: IFileContentHasher {

// MARK: - hashContext

var hashContextPathsThrowableError: Error?
var hashContextPathsCallsCount = 0
var hashContextPathsCalled: Bool { hashContextPathsCallsCount > 0 }
var hashContextPathsReceivedPaths: [String]?
var hashContextPathsReceivedInvocations: [[String]] = []
var hashContextPathsReturnValue: [String]!
var hashContextPathsClosure: (([String]) async throws -> [String])?

func hashContext(paths: [String]) async throws -> [String] {
if let error = hashContextPathsThrowableError {
throw error
}
hashContextPathsCallsCount += 1
hashContextPathsReceivedPaths = paths
hashContextPathsReceivedInvocations.append(paths)
if let hashContextPathsClosure = hashContextPathsClosure {
return try await hashContextPathsClosure(paths)
} else {
return hashContextPathsReturnValue
}
}
}

// swiftlint:enable all
39 changes: 39 additions & 0 deletions Tests/FoundationTests/Mocks/IXcodeEnvResolverMock.generated.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Generated using Sourcery 2.1.1 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

// swiftlint:disable all

import Foundation
@testable import RugbyFoundation

final class IXcodeEnvResolverMock: IXcodeEnvResolver {

// MARK: - resolve

var resolvePathAdditionalEnvThrowableError: Error?
var resolvePathAdditionalEnvCallsCount = 0
var resolvePathAdditionalEnvCalled: Bool { resolvePathAdditionalEnvCallsCount > 0 }
var resolvePathAdditionalEnvReceivedArguments: (path: String, additionalEnv: [String: String])?
var resolvePathAdditionalEnvReceivedInvocationsLock = NSLock()
var resolvePathAdditionalEnvReceivedInvocations: [(path: String, additionalEnv: [String: String])] = []
var resolvePathAdditionalEnvReturnValue: String!
var resolvePathAdditionalEnvClosure: ((String, [String: String]) async throws -> String)?

func resolve(path: String, additionalEnv: [String: String]) async throws -> String {
if let error = resolvePathAdditionalEnvThrowableError {
throw error
}
resolvePathAdditionalEnvCallsCount += 1
resolvePathAdditionalEnvReceivedArguments = (path: path, additionalEnv: additionalEnv)
resolvePathAdditionalEnvReceivedInvocationsLock.withLock {
resolvePathAdditionalEnvReceivedInvocations.append((path: path, additionalEnv: additionalEnv))
}
if let resolvePathAdditionalEnvClosure = resolvePathAdditionalEnvClosure {
return try await resolvePathAdditionalEnvClosure(path, additionalEnv)
} else {
return resolvePathAdditionalEnvReturnValue
}
}
}

// swiftlint:enable all
6 changes: 6 additions & 0 deletions Tests/FoundationTests/Mocks/Mocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ extension IXcodeBuildExecutor {}
//// sourcery: AutoMockable, imports = ["RugbyFoundation"]
extension FoundationHasher {}

//// sourcery: AutoMockable, imports = ["RugbyFoundation"]
extension IFileContentHasher {}

//// sourcery: AutoMockable, imports = ["RugbyFoundation"]
extension IXcodeEnvResolver {}

//// sourcery: AutoMockable, imports = ["RugbyFoundation"]
extension ISwiftVersionProvider {}

Expand Down

0 comments on commit c1727b7

Please sign in to comment.