Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create Mock for method which has typed-throws in the signature #520

Open
dr-star opened this issue Nov 11, 2024 · 1 comment
Open

Comments

@dr-star
Copy link

dr-star commented Nov 11, 2024

Hello All!,

If a function signature uses the new Typed throws introduced with Swift 6, Cuckoo doesn't generate mocks properly.
For example I use throws(APIError) the file into GeneratedMocks.swift has only throws

import Foundation
import Factory

protocol RegistrationServiceProtocol {
    func registration(name: String, surname: String, email: String, password: String) async throws(APIError) -> UUID
}

class RegistrationService: RegistrationServiceProtocol {
    @Injected(\.registrationClient) var registrationClient: RegistrationClientProtocol
    
    func registration(name: String, surname: String, email: String, password: String) async throws(APIError) -> UUID {
        let request = UserRegistrationRequest(name: name, surname: surname, email: email, password: password)
        
        return try await registrationClient.register(request: request)
    }
}

The generate mock into "GeneratedMocks" doesn't have the " same signature as the interface, instead it has

override func registration(name p0: String, surname p1: String, email p2: String, password p3: String) async throws

with the following error Type 'RegistrationServiceProtocolStub' does not conform to protocol 'RegistrationServiceProtocol'

@MatyasKriz
Copy link
Collaborator

Hey, yeah, this isn't supported at the moment. I don't think we're using SwiftSyntax 6 yet, though after its integration adding support for this shouldn't be too hard generator-wise. Not sure about the runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants