When the golden tests for K8s Config Connector mock output diverge from real GCP output, we need to inspect the discrepancies and fix either the mock implementation or the normalizers. This ensures that hack/compare-mock runs cleanly and accurately represents GCP API contracts.
How to use
Look closely at the compare-mock HTTP log differences (typically mock on left => real on right).
For missing default values (e.g., <missing> => REGIONAL), add a populateDefaultsFor<Resource> function to the mock service's file (e.g. mockgcp/mockcompute/networksv1.go). Make sure it is called on Insert and Get.
For generated IDs or volatile values (e.g. IPs, resource URLs) where real GCP generates dynamically but mockgcp outputs something static, you need to update the normalizer mockgcp/mock<service>/normalize.go.
Run hack/compare-mock "fixtures/^<testname>$" to see the diff and overwrite _http.log.
Run git diff on the test fixtures to ensure that the golden _http.log accurately replaces volatile data with placeholder variables (e.g., ${ipAddress}).
Certain operation metadata values (e.g. done: <missing> => false) can be safely ignored as mock operations are generally simpler.
1---2name: fix-diffs-mockgcp3description: Skill: Fix MockGCP Diffs4---5# Skill: Fix MockGCP Diffs67## Overview89When the golden tests for K8s Config Connector mock output diverge from real GCP output, we need to inspect the discrepancies and fix either the mock implementation or the normalizers. This ensures that `hack/compare-mock` runs cleanly and accurately represents GCP API contracts.1011## How to use12131. Look closely at the `compare-mock` HTTP log differences (typically mock on left `=>` real on right).142. For missing default values (e.g., `<missing> => REGIONAL`), add a `populateDefaultsFor<Resource>` function to the mock service's file (e.g. `mockgcp/mockcompute/networksv1.go`). Make sure it is called on `Insert` and `Get`.153. For generated IDs or volatile values (e.g. IPs, resource URLs) where real GCP generates dynamically but mockgcp outputs something static, you need to update the normalizer `mockgcp/mock<service>/normalize.go`.164. Run `hack/compare-mock "fixtures/^<testname>$"` to see the diff and overwrite `_http.log`.175. Run `git diff` on the test fixtures to ensure that the golden `_http.log` accurately replaces volatile data with placeholder variables (e.g., `${ipAddress}`).186. Certain operation metadata values (e.g. `done: <missing> => false`) can be safely ignored as mock operations are generally simpler.
Run npx skillmds@latest add googlecloudplatform/fix-diffs-mockgcp in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Skill: Fix MockGCP Diffs It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
GoogleCloudPlatform (@googlecloudplatform) published this skill. Their other Agent Skills are listed on their SkillMD profile.