Skip to main content

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.

Zur Installation springen

Quellinformationen

Repository
epam/edp-keycloak-operator
Letzte Quellaktivität
2. September 2026 um 11:44
Erkannte Sprache von SKILL.md
Englisch
Sterne
94
Forks
38

Installationsoptionen

Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.

Quelldateien prüfen

Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.

SKILL.md wird angezeigt

SKILL.md
Quellanweisungen · Schreibgeschützte Vorschau
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 *)
## Your task 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. --- ## Step 1 — Read .mockery.yml Read `.mockery.yml` to understand the current package/interface registrations. Key structure: ```yaml packages: github.com/epam/edp-keycloak-operator/<pkg-path>: interfaces: InterfaceName: {} ``` Generated filename pattern: `{{ .InterfaceName | snakecase }}_generated.mock.go` Output directory: `<package_dir>/mocks/` --- ## Step 2 — Locate the interface in source (skip if `$ARGUMENTS` is empty) Use Grep to find `type <InterfaceName> interface` in `pkg/` and `internal/`. Derive the Go import path from the file path: - Use the **directory** of the file (not the file itself) - Prepend `github.com/epam/edp-keycloak-operator/` - Example: `pkg/client/keycloakapi/contracts.go` → package `github.com/epam/edp-keycloak-operator/pkg/client/keycloakapi` --- ## Step 3 — Update .mockery.yml if needed (skip if `$ARGUMENTS` is empty) Add only the missing entries with a targeted Edit; the file registers every mocked interface in the repo, and a rewrite drops the ones outside this task: - Interface already registered → nothing to do, skip to Step 4. - Package present, interface missing → insert ` InterfaceName: {}` under its `interfaces:` block. - Package not present → append a new package entry at the end of the `packages:` block. --- ## Step 4 — Run make mocks ``` make mocks ``` --- ## Step 5 — Verify output 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.
Auf GitHub ansehen