22 lines
850 B
Go
22 lines
850 B
Go
package proposal_generation
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestRepairRequestJSONPreservesCurrentVersionAndFindings(t *testing.T) {
|
|
request := RepairRequest{ProposalRef: 3, Correction: StructuredCorrectionProposal{SegmentReference: 2, OriginalText: " ", CorrectedText: "", Confidence: 0.7}, Findings: []RepairFinding{{Validator: "first", Reason: "rejected", Explanation: "detail"}, {Validator: "second", Status: "unavailable", Reason: "provider_failed"}}}
|
|
text, err := request.JSON()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var got RepairRequest
|
|
if err := json.Unmarshal([]byte(text), &got); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got.ProposalRef != 3 || got.Correction != request.Correction || len(got.Findings) != 2 || got.Findings[0] != request.Findings[0] || got.Findings[1] != request.Findings[1] {
|
|
t.Fatalf("request: %+v", got)
|
|
}
|
|
}
|