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
Proposal: actively replacing gomonkey and mockery in open source projects #18
Comments
That may include providing a base image which includes xgo, which can be used in github workflows to automating testing. |
gomonkey usages: https://github.com/kubeedge/kubeedge/blob/master/cloud/cmd/cloudcore/app/server_test.go#:~:text=gomonkey.NewPatches Running test without any setup gives the following error: $ go test -timeout 30s -run ^TestNegotiateTunnelPort$ github.com/kubeedge/kubeedge/cloud/cmd/cloudcore/app
--- FAIL: TestNegotiateTunnelPort (0.03s)
panic: permission denied [recovered]
panic: permission denied
goroutine 173 [running]:
testing.tRunner.func1.2({0x101acd880, 0x1031a1968})
/Users/xhd2015/installed/go1.21.7/src/testing/testing.go:1545 +0x238
testing.tRunner.func1()
/Users/xhd2015/installed/go1.21.7/src/testing/testing.go:1548 +0x397
panic({0x101acd880?, 0x1031a1968?})
/Users/xhd2015/installed/go1.21.7/src/runtime/panic.go:914 +0x21f
github.com/agiledragon/gomonkey.modifyBinary(0x101590500, {0xc00081f6dc, 0xc, 0x10191b620?})
/Users/xhd2015/Projects/xhd2015/kubeedge/vendor/github.com/agiledragon/gomonkey/modify_binary_darwin.go:11 +0x116 This is a valid case that can be replaced by xgo. |
Example: https://github.com/traas-stack/chaosmeta Total: 19 patches using gomonkey out of 74 cases, can all be rewritten using xgo |
Example: https://github.com/brokercap/Bifrost |
Update: so far two major blockers: |
Solution to first problem:
Solution to second problem: defer these mock/trap calls during init, defer them at the end of all init. |
This has been supported 5b757ae |
Next:
Heavy use: |
Replaced all gomonkey patches in iotexproject/iotex-core: iotexproject/iotex-core#4219 Update: TencentBlueKing/bk-bcs TencentBlueKing/bk-bcs#3099
|
|
Since gomonkey and mockery both aim to provide mock for go, each in different ways. And their method should be considered outdated as xgo has evovled.
Thus, I propose we find active projects(has commits in last 2 months) that are still using these two library, finding how their tests are written with the help of the 2 library, and try to create a PR to replace them with xgo, demonstrating that xgo is a better choice, even the choice of the state of art.
The text was updated successfully, but these errors were encountered: