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

Add github.com/matryer/moq style mocks into mockery #725

Open
wants to merge 54 commits into
base: master
Choose a base branch
from

Commits on Dec 23, 2023

  1. Internal registry for disambiguated imports, vars (vektra#141)

    * Internal registry for disambiguated imports, vars
    - Move functionality in the moq package partially into
      internal/{registry,template}.
    - Leverage registry to assign unique package and variable/method
      parameter names. Use import aliases if present in interface source
      package.
    BREAKING CHANGE: When the interface definition does not mention the
    parameter names, the field names in call info anonymous struct will be
    different.
    The new field names are generated using the type info (string -> s,
    int -> n, chan int -> intCh, []MyType -> myTypes, map[string]int ->
    stringToInt etc.).
    For example, for a string parameter previously if the field name was
    'In1', the new field could be 'S' or 'S1' (depends on number of
    string method parameters).
    * Refactor golden file tests to be table-driven
    * Fix sync pkg alias handling for moq generation
    * Improve, add tests (increase coverage)
    * Use $.Foo in template, avoid declaring variables
    $ is set to the data argument passed to Execute, that is, to the
    starting value of dot.
    Variables were declared to be able to refer to the parent context.
    * Consistent template field formatting
    * Use tabs in generated Godoc comments' example code
    * Minor simplification
    * go generate
    * Fix conflict for generated param name of pointer type
    
    Excellent work by @sudo-suhas.
    sudo-suhas authored and LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    e06c157 View commit details
    Browse the repository at this point in the history
  2. feat: support generic interface generation (vektra#175)

    Allow the generation of mocks for generics as introduced in golang 1.18
    cgorenflo authored and LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    36a85ce View commit details
    Browse the repository at this point in the history
  3. Go version independent moq output with consistent whitespace

    By tweaking whitespace in template
    sudo-suhas authored and LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    d1b2fd4 View commit details
    Browse the repository at this point in the history
  4. Add flag to enable mock reset methods (vektra#181)

    The optional with-resets flag adds methods to reset method calls. Calls
    can be reset individually or all at once with these.
    cbaker authored and LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    d411b15 View commit details
    Browse the repository at this point in the history
  5. updates

    LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    0028a34 View commit details
    Browse the repository at this point in the history
  6. Internal registry for disambiguated imports, vars (vektra#141)

    * Internal registry for disambiguated imports, vars
    - Move functionality in the moq package partially into
      internal/{registry,template}.
    - Leverage registry to assign unique package and variable/method
      parameter names. Use import aliases if present in interface source
      package.
    BREAKING CHANGE: When the interface definition does not mention the
    parameter names, the field names in call info anonymous struct will be
    different.
    The new field names are generated using the type info (string -> s,
    int -> n, chan int -> intCh, []MyType -> myTypes, map[string]int ->
    stringToInt etc.).
    For example, for a string parameter previously if the field name was
    'In1', the new field could be 'S' or 'S1' (depends on number of
    string method parameters).
    * Refactor golden file tests to be table-driven
    * Fix sync pkg alias handling for moq generation
    * Improve, add tests (increase coverage)
    * Use $.Foo in template, avoid declaring variables
    $ is set to the data argument passed to Execute, that is, to the
    starting value of dot.
    Variables were declared to be able to refer to the parent context.
    * Consistent template field formatting
    * Use tabs in generated Godoc comments' example code
    * Minor simplification
    * go generate
    * Fix conflict for generated param name of pointer type
    
    Excellent work by @sudo-suhas.
    sudo-suhas authored and LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    d16ef1b View commit details
    Browse the repository at this point in the history
  7. Fix var name generation to avoid conflict (vektra#145)

    When the type and the package name is the same for an anonymous
    parameter (ex: time.Time), and there are more than 1 such parameters,
    the generated name for both was the same. And the generated code would
    not be valid.
    
    Fix the bug by ensuring the parameter name does not conflict with
    package imports first before checking against other parameter names.
    sudo-suhas authored and LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    5ea7cda View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    2c9d05c View commit details
    Browse the repository at this point in the history
  9. Fix issue with custom types shadowing basic types (vektra#163)

    When a custom type has a name that can shadow an in-built type, append
    MoqParam to the name. Example: var name stringMoqParam for null.String.
    dedalusj authored and LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    9e0e5d0 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    92a6e93 View commit details
    Browse the repository at this point in the history
  11. feat: support generic interface generation (vektra#175)

    Allow the generation of mocks for generics as introduced in golang 1.18
    cgorenflo authored and LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    4468afa View commit details
    Browse the repository at this point in the history
  12. Recursively check unique pkg names against existing imports

    When we generate a unique name for pkg a on conflict with pkg b, the new
    name could already be in use for pkg c. So recursively check each unique
    name against existing imports before setting it.
    sudo-suhas authored and LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    fb12cf9 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    ebe7652 View commit details
    Browse the repository at this point in the history
  14. Do not load unnecessary package information (vektra#203)

    - Add benchmark test for registry.New
    samherrmann authored and LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    222a8a9 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    1d04e7d View commit details
    Browse the repository at this point in the history
  16. updates

    LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    e68ee26 View commit details
    Browse the repository at this point in the history
  17. updates

    LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    3eb17fe View commit details
    Browse the repository at this point in the history
  18. updates

    LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    860c2c8 View commit details
    Browse the repository at this point in the history
  19. Add more code to plumb through all the values needed by moq registry …

    …methods
    
    In this commit, we gather all the template data needed by the moq logic to
    generate its template. This is untested as of yet.
    
    TODO: need to start testing this works by calling upon `moq` in `.mockery.yaml`.
    LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    d66be2c View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    1edd82f View commit details
    Browse the repository at this point in the history
  21. add config for moq

    LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    f19f1f1 View commit details
    Browse the repository at this point in the history
  22. add formatter back

    LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    852b19e View commit details
    Browse the repository at this point in the history
  23. fix

    LandonTClipp committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    9d89443 View commit details
    Browse the repository at this point in the history

Commits on Feb 12, 2024

  1. change moq.templ comment

    LandonTClipp committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    9aa5b53 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1f078dc View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e3fe47c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    62ef480 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5d37c18 View commit details
    Browse the repository at this point in the history

Commits on Feb 13, 2024

  1. Move generator to separate package

    Disable generating mocks for functions in templated mocks
    LandonTClipp committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    f9bee27 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2ded465 View commit details
    Browse the repository at this point in the history
  3. fix config

    LandonTClipp committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    f144fb5 View commit details
    Browse the repository at this point in the history
  4. Add mocks for moq

    LandonTClipp committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    4a1905b View commit details
    Browse the repository at this point in the history
  5. fix config

    LandonTClipp committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    d25b5da View commit details
    Browse the repository at this point in the history
  6. fix taskfile

    LandonTClipp committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    63653e0 View commit details
    Browse the repository at this point in the history
  7. Split out warn logs to logging package

    Add warning when using `moq` style
    LandonTClipp committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    a0f012b View commit details
    Browse the repository at this point in the history
  8. Add template-map config param.

    Factor out TypeInstantiation into separate function.
    LandonTClipp committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    19b9718 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    db5f5a6 View commit details
    Browse the repository at this point in the history
  10. update moq mocks

    LandonTClipp committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    05f2c4d View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    587f197 View commit details
    Browse the repository at this point in the history
  12. fix tests

    LandonTClipp committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    1805cf2 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    0aa59fb View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    cdd540b View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    ddf4a43 View commit details
    Browse the repository at this point in the history
  16. fix to go.mod logic

    LandonTClipp committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    7f4d02d View commit details
    Browse the repository at this point in the history

Commits on Feb 21, 2024

  1. Configuration menu
    Copy the full SHA
    78eb414 View commit details
    Browse the repository at this point in the history
  2. Change name of moq mocks

    LandonTClipp committed Feb 21, 2024
    Configuration menu
    Copy the full SHA
    f0de03c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a82b265 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a9aac88 View commit details
    Browse the repository at this point in the history
  5. update moqs

    LandonTClipp committed Feb 21, 2024
    Configuration menu
    Copy the full SHA
    f57f7b1 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    dd61c0f View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    c8a2304 View commit details
    Browse the repository at this point in the history
  8. updates

    LandonTClipp committed Feb 21, 2024
    Configuration menu
    Copy the full SHA
    37562c5 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    4ddd30b View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    8ff0a85 View commit details
    Browse the repository at this point in the history