test(agent): compare persisted reproduction JSON semantically

This commit is contained in:
MuCheng committed 2026-10-27 17:34:03 +08:00
1 parent 867e3fd1c5
commit fb0146f4b6
1 file changed
+12 -1
+12 -1
View File
@@ -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)
}
}