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
Standardize go:generate for controller mocks + CI drift validation #2707
Per Harsh Rawat (@rawahars)'s review on #2647: the go:generate directive should reside in the test file, and we should validate generated mocks in CI.
Goals
Add a //go:generate directive (in a TEST file) for each controller that has mocks.
Add CI validation that runs go generate ./... and fails if there is any diff against the committed mock files. This catches mock drift when interfaces change but mocks are not regenerated.
Affected packages
internal/controller/device/scsi/
internal/controller/device/plan9/
internal/controller/device/vpci/
internal/controller/network/
internal/controller/vm/
internal/windows/ (mock at internal/windows/mock/)
internal/gcs/ (GuestDefinedCapabilities mock at internal/gcs/mock/)
cmd/containerd-shim-lcow-v2/service/
Future controllers should follow the same convention.
Suggested CI step
Extend an existing lint job in .github/workflows/ci.yml:
- name: Verify generated mocks are up to daterun: | go generate ./... git diff --exit-code -- '*/mocks/*.go' '*/mock/*.go'
Run on windows-latest so build tags resolve correctly.
Acceptance criteria
Each listed package has a //go:generate directive in a test file
go generate ./... produces no diff against committed mocks on a fresh clone
CI fails if a contributor changes an interface without regenerating
CONTRIBUTING.md (or equivalent) documents the regeneration workflow
Notes
Discussed in #2647 (review on internal/controller/network/network_lcow.go).
Activity
service: add unit tests for LCOW v2 shim service layer
service: add unit tests for LCOW v2 shim service layer
service: add unit tests for LCOW v2 shim service layer
service: add unit tests for LCOW v2 shim service layer (#2649)