一键导入
generate-mocks
// Use when generating testify mocks for an interface. Ensures the interface is registered in .mockery.yml, runs make mocks, and verifies the output file.
// Use when generating testify mocks for an interface. Ensures the interface is registered in .mockery.yml, runs make mocks, and verifies the output file.
Use when adding a new field to an existing Custom Resource. Guides the full workflow: API types, code generation, CRD examples, client investigation, handler mapping, and tests.
Run tests for the edp-keycloak-operator. By default runs unit + integration tests. Use /run-tests e2e for end-to-end tests.
Run golangci-lint linters and fix any linting errors. Use when fixing lint issues or before committing code.
| name | generate-mocks |
| description | Use when generating testify mocks for an interface. Ensures the interface is registered in .mockery.yml, runs make mocks, and verifies the output file. |
| allowed-tools | Read, Grep, Glob, Bash(make *) |
Generate mocks for one or more interfaces. $ARGUMENTS contains the interface name(s) to add/verify (may be empty — in that case just regenerate all existing mocks).
Work through all steps in order.
Read .mockery.yml to understand the current package/interface registrations.
Key structure:
packages:
github.com/epam/edp-keycloak-operator/<pkg-path>:
interfaces:
InterfaceName: {}
Generated filename pattern: {{ .InterfaceName | snakecase }}_generated.mock.go
Output directory: <package_dir>/mocks/
$ARGUMENTS is empty)Use Grep to find type <InterfaceName> interface in pkg/ and internal/.
Derive the Go import path from the file path:
github.com/epam/edp-keycloak-operator/pkg/client/keycloakapi/contracts.go → package github.com/epam/edp-keycloak-operator/pkg/client/keycloakapi$ARGUMENTS is empty)Use targeted Edit (never rewrite the whole file) to add only what is missing:
InterfaceName: {} under its interfaces: block.packages: block.make mocks
Use Glob to confirm the generated file exists at the expected path.
Expected path: <package_filesystem_dir>/mocks/<interface_name_snakecase>_generated.mock.go
Example: UsersClient in pkg/client/keycloakapi/ → pkg/client/keycloakapi/mocks/users_client_generated.mock.go
Report the verified path to the user.