Files
Agent-System/internal/traceimpact/service_empty_lists_test.go
T
weichenandCursor 1f7f3d2271 test(trace): guard empty trace lists against JSON null
Cover the service nil-slice contract and the client normalization of a null payload.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-21 02:38:08 +00:00

39 lines
852 B
Go

package traceimpact
import (
"context"
"encoding/json"
"strings"
"testing"
)
func TestListMethodsReturnEmptySlicesNotNil(t *testing.T) {
svc := NewService(nil)
ctx := context.Background()
items, err := svc.ListItems(ctx, 42)
if err != nil || items == nil {
t.Fatalf("ListItems items=%v err=%v", items, err)
}
index, err := svc.ListIndex(ctx, 42)
if err != nil || index == nil {
t.Fatalf("ListIndex index=%v err=%v", index, err)
}
marks, err := svc.ListOpenMarks(ctx, 42, "")
if err != nil || marks == nil {
t.Fatalf("ListOpenMarks marks=%v err=%v", marks, err)
}
raw, err := json.Marshal(map[string]any{
"items": items,
"index": index,
"recheck_marks": marks,
})
if err != nil {
t.Fatal(err)
}
if strings.Contains(string(raw), "null") {
t.Fatalf("empty lists encoded as JSON null: %s", raw)
}
}