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 include-regex option #692

Merged
merged 2 commits into from
Aug 21, 2023
Merged

Conversation

leaanthony-sc
Copy link
Contributor

@leaanthony-sc leaanthony-sc commented Aug 16, 2023

Description

Prior to packages configuration, it was possible to pass a regex to filter which interfaces are considered for mocking. This reintroduces the feature using the include-regex option for package configurations.

Example config:

packages:
  github.com/user/project:
    config:
      recursive: True
      include-regex: ".*Client"

In addition to this feature, a number of variables named packages have been renamed to packageList as they were clashing with package names.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Version of Golang used when building/testing:

  • 1.21

How Has This Been Tested?

Tests have been added to config_test.go. These test the following scenarios:

all include-regex outcome
True "" All interfaces match
True ".*Client" All interfaces match. A warning is printed
False ".*Client" Only interfaces ending in Client are generated

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@leaanthony-sc
Copy link
Contributor Author

@LandonTClipp - I'm not super familiar with the codebase or coding style so feel free to make any suggestions/changes. Thanks for your time!

Copy link
Contributor

@LandonTClipp LandonTClipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, I actually don't have any concerns. It's basically exactly how I would have implemented it. Thanks for taking the time to do this!

Copy link
Contributor

@LandonTClipp LandonTClipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, just one minor doc change and we should be set.

```

??? note "all: true"
Using `all: true` will override `include-regex` and issue a warning.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually one thing I did miss, you'll want to also include this parameter in the configuration section of the docs in that large table.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs updated 👍 I took the liberty of reformatting the markdown tables so they are easily readable in raw text. Can revert that if you want.

@leaanthony-sc
Copy link
Contributor Author

@LandonTClipp Is there anything else you'd like adding to this or are we good to go? Thanks 🙏

@LandonTClipp
Copy link
Contributor

Nothing else I think we need, I'll give it one last look this Monday and merge if it looks good.

Sorry, I have been on an extended camping trip out west and have not been focusing on coding much 😄

@LandonTClipp LandonTClipp merged commit 6ada211 into vektra:master Aug 21, 2023
3 checks passed
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

Successfully merging this pull request may close these issues.

--name doesn't accept regex values
2 participants