You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
chore: Make the psutil mock available to tests without shipping it in the binary #19375
Follow-up to #19315, and the one remaining testify leaker that is not a simple file rename.
plugins/common/psutil/mock_ps.go is a non-test file, so it is compiled into the shipped binary and brings testify with it.
It cannot just be renamed to *_test.go, because the symbols it exports (MockPS, MockPSDisk, MockDiskUsage) are used by tests in eight other packages:
plugins/inputs/conntrack
plugins/inputs/disk
plugins/inputs/diskio
plugins/inputs/mem
plugins/inputs/net
plugins/inputs/netstat
plugins/inputs/swap
A _test.go file is not importable across package boundaries, so this needs one of:
Move the mock into its own package, for example plugins/common/psutil/psutiltest, and have the consumers import that. The mock stays in the module but is no longer reachable from ./cmd/telegraf, which is what matters here. Smallest diff.
Give each consumer its own local mock. Removes the shared dependency but duplicates it eight times.
Option 1 looks right, but it touches eight test files, so worth agreeing on before someone writes it.
Related
testutil/plugin_input/plugin.go is the same shape waiting to happen: a non-test file importing testutil. It is harmless only for as long as nothing reachable from the binary imports it.
#19373 proposes a CI guard so this class fails the build instead of being found by accident.
Verify
go list -deps ./cmd/telegraf | grep stretchr/testify
Activity