Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Hard to debug when a Do(fn) function no longer matches its mock signature #71

@EtiennePerot

Description

@EtiennePerot

Situation: we had code like:

type Foo interface {
  Bar(arg1, arg2 string)
  ...
}

and tests like:

do := func(arg1, arg2 string) { ... }
// ... bunch of code ...
myBarMock.EXPECT().Bar(wantArg1, wantArg2).Do(do)

Then we added an argument to Bar:

type Foo interface {
  Bar(arg1, arg2, arg3 string)
  ...
}

and updated the EXPECT():

do := func(arg1, arg2 string) { ... }
// ... bunch of code ...
myBarMock.EXPECT().Bar(wantArg1, wantArg2, wantArg3).Do(do)

... but forgot to update do. The result was "panic: reflect: Call with too many input arguments" with no strong indication that what was wrong was the do function, rather than some place where the third argument hadn't been added (e.g. missing wantArg3).
It would be nice if the message said something more obvious like "EXPECT.()Do() function doesn't match the mock signature".

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy