Fix MockGCP Diffs

Resolve golden test mismatches between mockgcp output and real GCP API responses.

1.1k|367|Updated Apr 8, 2019
One-click install
npx skills add https://github.com/GoogleCloudPlatform/k8s-config-connector --skill fix-mockgcp-diffs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Fix MockGCP Diffs
Source: https://github.com/GoogleCloudPlatform/k8s-config-connector/tree/main/mockgcp/.gemini/skills/fix-diffs-mockgcp
Command: npx skills add https://github.com/GoogleCloudPlatform/k8s-config-connector --skill fix-mockgcp-diffs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Fixing golden mock diffs that drift from real GCP behavior causes noisy test failures and unreliable validation of API contracts. This Skill helps you identify whether discrepancies come from missing mock defaulting logic or from normalization of volatile fields.

Core Features & Use Cases

  • Diff-driven debugging: Use hack/compare-mock output to pinpoint where mock vs real responses diverge.
  • Mock default parity: Add populateDefaultsFor<Resource> calls so server-side defaults appear consistently in mock responses for both Insert and Get paths.
  • Normalizer updates for volatility: Update mockgcp/mock<service>/normalize.go to ensure generated IDs and dynamic values (like IPs/URLs) are represented deterministically in golden fixtures.
  • Golden fixture stabilization: Re-run comparisons and update _http.log while replacing volatile values with placeholder variables to keep tests stable.

Quick Start

Run hack/compare-mock for the failing fixture test name, then update the mock defaults or normalization logic until the regenerated golden _http.log diff is clean.

Frequently Asked Questions about Fix MockGCP Diffs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why do my golden test fixtures fail with diffs between mockgcp and real GCP API responses?

Golden test diffs between mockgcp and real GCP APIs occur when mock responses lack server-side defaults or fail to normalize volatile identifiers like dynamic IPs and generated URLs into deterministic placeholders.

How do I stabilize volatile values in k8s-config-connector mockgcp HTTP logs?

To stabilize volatile values in mockgcp HTTP logs, update the mockgcp normalizers in normalize.go to consistently replace dynamically generated IDs, IPs, and URLs with deterministic placeholder variables in your golden fixtures.

How do I add server-side defaults to mock GCP Insert and Get operations?

Add server-side defaults to mock GCP operations by implementing populateDefaultsFor<Resource> hooks in your mock service implementations, ensuring both Insert and Get paths consistently return expected defaulted fields.

What is the best way to debug k8s config connector mock and real GCP API contract mismatches?

The best way to debug k8s config connector API contract mismatches is running hack/compare-mock workflows to pinpoint divergences, then iteratively updating mock defaults and normalizers until the regenerated _http.log diff is clean.

When should I update mockgcp normalizers instead of mock defaulting logic for golden test diffs?

Update mockgcp normalizers instead of mock defaulting logic when golden test discrepancies stem from volatile fields like dynamically generated IDs and URLs, rather than missing server-side defaulted fields in the mock responses.