MakeAWishFoundation/SwiftyMocky

Invalid redeclaration error when generating some async method mocks

hufkens opened this issue · 0 comments

We are using async functions and we ran into a problem while generating mocks.

We have an APIClient that has these methods:

func request<T: Decodable>(_ request: URLRequestConvertible) async throws -> T
func request(_ request: URLRequestConvertible) async throws

After generating the mocks SwiftyMocky v 4.1.0 we get this error: Invalid redeclaration of 'request(_:willThrow:)' because 2 methods have been generated.

public static func request(_ request: Parameter<URLRequestConvertible>, willThrow: Error...) -> MethodStub {
    return Given(method: .m_request__request_1(`request`), products: willThrow.map({ StubProduct.throw($0) }))
}

public static func request(_ request: Parameter<URLRequestConvertible>, willThrow: Error...) -> MethodStub {
    return Given(method: .m_request__request_2(`request`), products: willThrow.map({ StubProduct.throw($0) }))
}

We found this closed ticket #290 and for most of our code the tests without async work fine.

But we also saw that the new Sourcery added support for parsing async methods in their latest 1.7.0 update. https://github.com/krzysztofzablocki/Sourcery/blob/master/CHANGELOG.md

Would it be possible to look into supporting async in the new version?

Thanks
Alain