返回 DeepSeek-Reasonix
model_submission_test.go
根目录 / internal / serve / model_submission_test.go
1 package serve
2
3 import (
4 "encoding/json"
5 "errors"
6 "net/http/httptest"
7 "testing"
8
9 "reasonix/internal/control"
10 )
11
12 func TestSubmissionErrorPreservesUnknownDurabilityOutcome(t *testing.T) {
13 for _, tc := range []struct {
14 err error
15 outcome string
16 }{
17 {errors.New("receipt persistence failed"), "unknown"},
18 {errors.Join(control.ErrSubmissionNotAccepted, errors.New("configuration pending")), "not_accepted"},
19 } {
20 response := httptest.NewRecorder()
21 writeSubmissionFailure(response, tc.err)
22 var body struct {
23 Data struct {
24 Outcome string `json:"submissionOutcome"`
25 } `json:"data"`
26 }
27 if err := json.Unmarshal(response.Body.Bytes(), &body); err != nil {
28 t.Fatal(err)
29 }
30 if body.Data.Outcome != tc.outcome {
31 t.Fatalf("outcome=%q, want %q", body.Data.Outcome, tc.outcome)
32 }
33 }
34 }
35
35 lines GO