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

Refactor mock name generation #452

Merged
merged 1 commit into from Apr 21, 2022

Conversation

grongor
Copy link
Contributor

@grongor grongor commented Apr 19, 2022

Also fix name for unexported InPackage mocks (was Mocklowercase and nowis MockUppercase, as expected)


This is a response PR to #406 (comment)

I didn't find any similar usages across the code base, but maybe I just missed them? If so, please, point me to them and I'll have another look at it :)

Please note that this changes how private mocks are generated when they are called with --exported. If this is an issue (it's BC), I can revert it/change it, but I think this is a bug fix and not a "change" per say... depends :) Your call.

return name
}

return string(unicode.ToUpper(r)) + name[n:]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

by the way I made some quick benchmarks and this seems to be the best way to do this...it is much faster than string -> []rune -> string conversions

mock := &Mockrequester_unexported{}
// NewMockRequester_unexported creates a new instance of MockRequester_unexported. It also registers a cleanup function to assert the mocks expectations.
func NewMockRequester_unexported(t testing.TB) *MockRequester_unexported {
mock := &MockRequester_unexported{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately this is a breaking change so we'll need to revert this back to the old (incorrect) behavior :'(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I thought so, no problem. But please, keep that in mind for v3, I think this should be fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally agreed. I will keep this PR open and add it to the v3 list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okey, so, should I add the breaking change back? :D I think it would be better to merge this now (it's non-BC), and I'll post another PR for v3...what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see yeah we can get this merged now since you reverted the breaking change. Thanks!

@grongor grongor force-pushed the refactor-first-letter-helper branch from 6e96703 to 749b2d6 Compare April 20, 2022 10:21
@codecov-commenter
Copy link

codecov-commenter commented Apr 20, 2022

Codecov Report

Merging #452 (749b2d6) into master (4af1288) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #452      +/-   ##
==========================================
- Coverage   70.76%   70.75%   -0.02%     
==========================================
  Files           7        7              
  Lines        1293     1289       -4     
==========================================
- Hits          915      912       -3     
+ Misses        325      324       -1     
  Partials       53       53              
Impacted Files Coverage Δ
pkg/generator.go 90.92% <100.00%> (+0.10%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4af1288...749b2d6. Read the comment docs.

@LandonTClipp LandonTClipp added this to To do in v3 Apr 21, 2022
@LandonTClipp LandonTClipp removed the v3 label Apr 21, 2022
@LandonTClipp LandonTClipp merged commit 58a7f18 into vektra:master Apr 21, 2022
v3 automation moved this from To do to Done Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
v3
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants