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

Unable to mock getty.Session interface, due to composition with unexported functions in getty.Connection. #71

Open
iSuperCoder opened this issue Jul 26, 2023 · 1 comment

Comments

@iSuperCoder
Copy link

What would you like to be added:
To resolve this problem, it is necessary to modify all the functions defined in getty.Connection to be exported with uppercase names.

Why is this needed:
Seata-go references getty, and encountered obstacles when writing unit tests related to the getty.Session interface. Neither gomock nor gomonkey can mock the getty.Session interface.

The issue arises from the fact that the getty.Connection interface defines lowercase unexported functions, and the getty.Session interface composes getty.Connection, making it impossible to mock getty.Session from outside the getty package.

@iSuperCoder
Copy link
Author

gomonkey can stub non-exported private functions, but the prerequisite is to have a struct instance. Due to the aforementioned issue with getty.Connection, it's not possible to create a getty.Session interface instance outside the getty package.

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

No branches or pull requests

1 participant