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

Bug on variables and methods name creations, using tuples as parameters, AutoMockable #1372

Open
diogoppires opened this issue Oct 14, 2024 · 0 comments

Comments

@diogoppires
Copy link

Hello,

I'm facing an issue with the AutoMockable tool.

When a method has a parameter with a tuple, in this case with 3 values, the generated variables and functions for this method in the mock file, are being broken.

Protocol
// sourcery: AutoMockable
protocol TestProtocol {
    
    func method(
        name: String,
        data: (
            yearly: [Int],
            monthly: [Int],
            daily: [Int]
        )
    ) -> [String]
}
Generated code
class TestProtocolMock: TestProtocol {
    //MARK: - method

    var methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringCallsCount = 0
    var methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringCalled: Bool {
        return methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringCallsCount > 0
    }
    var methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringReceivedArguments: (name: String, data: (
            yearly: [Int],
            monthly: [Int],
            daily: [Int]
        ))?
    var methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringReceivedInvocations: [(name: String, data: (
            yearly: [Int],
            monthly: [Int],
            daily: [Int]
        ))] = []
    var methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringReturnValue: [String]!
    var methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringClosure: ((String, (
            yearly: [Int],
            monthly: [Int],
            daily: [Int]
        )) -> [String])?

    func method(name: String, data: (
            yearly: [Int],
            monthly: [Int],
            daily: [Int]
        )) -> [String] {
        methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringCallsCount += 1
        methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringReceivedArguments = (name: name, data: data)
        methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringReceivedInvocations.append((name: name, data: data))
        if let methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringClosure = methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringClosure {
            return methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringClosure(name, data)
        } else {
            return methodNameStringData
YearlyInt
MonthlyInt
DailyInt
StringReturnValue
        }
    }
}

Does anyone know a solution to this problem?

Thank you

Sourcery version: 2.2.5

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

No branches or pull requests

1 participant