From 2aff6daf8fe41f17ea674872a30d34cf1097b046 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 29 May 2026 11:57:37 +0000 Subject: [PATCH 1/2] test(adcp): add explicit Budget.Committed zero round-trip case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Strengthens TestPlanAuditLogsRoundTrip (issue #306) with a second fixture where Budget.Committed is explicitly 0. Asserts the field unmarshals as a non-nil *float64 pointer and re-marshals as "committed":0 inside the "budget" object — distinct from PlanAuditGovernedAction.Committed (a non-pointer float64). Uses a minimal fixture without empty slices to avoid silent omitempty round-trip asymmetry on Entries. https://claude.ai/code/session_01WBzJCnaT7zEFovwELGVceo --- adcp/generated_core_refs_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/adcp/generated_core_refs_test.go b/adcp/generated_core_refs_test.go index ab8434b..6d83e16 100644 --- a/adcp/generated_core_refs_test.go +++ b/adcp/generated_core_refs_test.go @@ -839,6 +839,29 @@ func TestPlanAuditLogsRoundTrip(t *testing.T) { if strings.Contains(body, `"committed":null`) { t.Fatalf("plan audit logs unexpectedly marshaled absent budget.committed:\n%s", body) } + + // Contrast: budget.committed explicitly zero must round-trip as "committed":0 inside + // the "budget" object, not be omitted. Distinct from PlanAuditGovernedAction.Committed + // (a non-pointer float64) whose presence in the output is unrelated. + raw2 := []byte(`{"plans":[{"plan_id":"plan-2","plan_version":1,"status":"active","budget":{"authorized":5000,"committed":0},"summary":{}}]}`) + var decoded2 GetPlanAuditLogsResponse + if err := json.Unmarshal(raw2, &decoded2); err != nil { + t.Fatalf("unmarshal plan audit logs with explicit committed zero: %v", err) + } + if len(decoded2.Plans) != 1 { + t.Fatalf("plans len = %d, want 1", len(decoded2.Plans)) + } + plan2 := decoded2.Plans[0] + if plan2.Budget.Committed == nil || *plan2.Budget.Committed != 0 { + t.Fatalf("budget.committed = %#v, want explicit pointer to 0", plan2.Budget.Committed) + } + encoded2, err := json.Marshal(decoded2) + if err != nil { + t.Fatalf("marshal plan audit logs with explicit committed zero: %v", err) + } + if !strings.Contains(string(encoded2), `"budget":{"authorized":5000,"committed":0}`) { + t.Fatalf("explicit Budget.Committed:0 did not round-trip inside budget object (check Budget.Committed is *float64 with omitempty):\n%s", encoded2) + } } func TestGovernanceFindingsRoundTrip(t *testing.T) { From 62feb1be8b8f164c07713c0523c1852c908903c8 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 29 May 2026 11:59:45 +0000 Subject: [PATCH 2/2] test(adcp): address pre-PR review nits for issue-306 - Add governed_actions entry to raw2 fixture (non-omitempty field; also makes the Budget.Committed vs GovernedAction.Committed contrast explicit and verifiable in the data) - Use err2 instead of err to match raw2/decoded2/encoded2 naming - Improve final Fatalf hint to clarify *float64+omitempty semantics https://claude.ai/code/session_01WBzJCnaT7zEFovwELGVceo --- adcp/generated_core_refs_test.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/adcp/generated_core_refs_test.go b/adcp/generated_core_refs_test.go index 6d83e16..d4decc1 100644 --- a/adcp/generated_core_refs_test.go +++ b/adcp/generated_core_refs_test.go @@ -841,12 +841,13 @@ func TestPlanAuditLogsRoundTrip(t *testing.T) { } // Contrast: budget.committed explicitly zero must round-trip as "committed":0 inside - // the "budget" object, not be omitted. Distinct from PlanAuditGovernedAction.Committed - // (a non-pointer float64) whose presence in the output is unrelated. - raw2 := []byte(`{"plans":[{"plan_id":"plan-2","plan_version":1,"status":"active","budget":{"authorized":5000,"committed":0},"summary":{}}]}`) + // the "budget" object, not be omitted. The governed_actions entry also has "committed":0 + // (a non-pointer float64) — the scoped assertion on the "budget" object confirms we are + // checking PlanAuditBudget.Committed (*float64), not PlanAuditGovernedAction.Committed. + raw2 := []byte(`{"plans":[{"plan_id":"plan-2","plan_version":1,"status":"active","budget":{"authorized":5000,"committed":0},"summary":{},"governed_actions":[{"governance_context":"ctx-1","purchase_type":"media_buy","status":"active","committed":0,"check_count":0}]}]}`) var decoded2 GetPlanAuditLogsResponse - if err := json.Unmarshal(raw2, &decoded2); err != nil { - t.Fatalf("unmarshal plan audit logs with explicit committed zero: %v", err) + if err2 := json.Unmarshal(raw2, &decoded2); err2 != nil { + t.Fatalf("unmarshal plan audit logs with explicit committed zero: %v", err2) } if len(decoded2.Plans) != 1 { t.Fatalf("plans len = %d, want 1", len(decoded2.Plans)) @@ -855,12 +856,13 @@ func TestPlanAuditLogsRoundTrip(t *testing.T) { if plan2.Budget.Committed == nil || *plan2.Budget.Committed != 0 { t.Fatalf("budget.committed = %#v, want explicit pointer to 0", plan2.Budget.Committed) } - encoded2, err := json.Marshal(decoded2) - if err != nil { - t.Fatalf("marshal plan audit logs with explicit committed zero: %v", err) + encoded2, err2 := json.Marshal(decoded2) + if err2 != nil { + t.Fatalf("marshal plan audit logs with explicit committed zero: %v", err2) } if !strings.Contains(string(encoded2), `"budget":{"authorized":5000,"committed":0}`) { - t.Fatalf("explicit Budget.Committed:0 did not round-trip inside budget object (check Budget.Committed is *float64 with omitempty):\n%s", encoded2) + t.Fatalf("explicit Budget.Committed:0 did not round-trip inside budget object"+ + " (Budget.Committed is *float64; nil pointer is omitted, pointer-to-zero is emitted even with omitempty):\n%s", encoded2) } }