minimock icon indicating copy to clipboard operation
minimock copied to clipboard

Bugs/improvements on union interfaces, diff displaying and version setting

Open zcolleen opened this issue 1 year ago • 2 comments

In this pr i introduce 3 bugs/improvements:

  1. We have to update gowrap when pr https://github.com/hexdigest/gowrap/pull/86 is merged, to fix generation of interfaces with unions and type approximations.

  2. Improvement with diff displaying: when test fails because expectations failed and we used minimock.Anycontext, the diff will show arguments that are different as well as context argument, e.g.

        Diff:
        --- Expected params
        +++ Actual params
        @@ -1,6 +1,4 @@
         (tests.ContextAccepterMockAcceptContextWithOtherArgsParams) {
        - ctx: (minimock.anyContext) {
        -  Context: (context.Context) <nil>
        - },
        - i1: (int) 24
        + ctx: (context.backgroundCtx) context.Background,
        + i1: (int) 123
         }

It is very confusing for developers as they think that there is also some issue with context, that anyContext is not working. So i improved diff displaying in that way that it wont show difference between context if anyContext is used, e.g.

        Diff:
        --- Expected params
        +++ Actual params
        @@ -4,3 +4,3 @@
          },
        - i1: (int) 24
        + i1: (int) 123
         }
  1. Improved version when displaying --version or setting it in generated code. The issue is that if you install minimock binary with go install, the version is set to 'dev', so in generated code minimock version is set to 'dev' making it impossible to understand which version of minimock has generated code, e.g.
// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.

So in this pr if version is not set, we will take version and commit from debug.ReadBuildInfo() .

  1. Some minor documentation update.

zcolleen avatar May 02 '24 21:05 zcolleen

Hey @zcolleen!

Thank you for the fix! I released v1.3.7 version of Gowrap, can you please update this pr (remove replace directive from go.mod).

hexdigest avatar May 03 '24 01:05 hexdigest

Hey @hexdigest ! Updated go.mod, double checked everything

zcolleen avatar May 03 '24 08:05 zcolleen