mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-11-04 19:43:50 +08:00
test(agent): compare persisted reproduction JSON semantically
This commit is contained in:
1 parent
867e3fd1c5
commit
fb0146f4b6
1 file changed
+12
-1
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user