From fb0146f4b67a68405810b12ed64e7ae2f84d8d80 Mon Sep 17 00:00:00 2001 From: MuCheng Date: Tue, 27 Oct 2026 17:34:03 +0800 Subject: [PATCH] test(agent): compare persisted reproduction JSON semantically --- agent/finding_recorder_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/agent/finding_recorder_test.go b/agent/finding_recorder_test.go index ae2be29..07e58fa 100644 --- a/agent/finding_recorder_test.go +++ b/agent/finding_recorder_test.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "reflect" "strings" "testing" @@ -74,7 +75,17 @@ func TestReportFindingPersistsStructuredReproduction(t *testing.T) { if err != nil { t.Fatal(err) } - if finding == nil || string(finding.Reproduction) != reproduction { + var wantReproduction, gotReproduction map[string]any + if err := json.Unmarshal([]byte(reproduction), &wantReproduction); err != nil { + t.Fatal(err) + } + if finding == nil { + t.Fatalf("reproduction was not persisted: %#v", finding) + } + if err := json.Unmarshal(finding.Reproduction, &gotReproduction); err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(gotReproduction, wantReproduction) { t.Fatalf("reproduction was not persisted: %#v", finding) } }