Why: backend main pinned core 019617e (unfetchable post-migration) and the store List* functions returned nil slices that encode as JSON null, which crashed the frontend nav with .map on null (the 2026-09-30 white-screen). Evidence: go test ./... across all packages; store regression TestEmptyListsSerializeAsEmptyArrays asserts [] for empty project lists. Impact: all 17 store list sites now initialize empty slices; build-blocker core pin resolved; frontend no longer receives null for empty lists. Refs: documents/records/2026-09-30-history-migration.md
29 lines
697 B
Go
29 lines
697 B
Go
package store
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
// 回归:空列表必须序列化为 [] 而非 null(前端 .map 白屏根因)。
|
|
func TestEmptyListsSerializeAsEmptyArrays(t *testing.T) {
|
|
s := openTestStore(t)
|
|
cs, err := s.ListConversations("owner_none", "prj_none")
|
|
if err != nil {
|
|
t.Fatalf("ListConversations: %v", err)
|
|
}
|
|
if cs == nil {
|
|
t.Fatal("ListConversations returned nil slice")
|
|
}
|
|
if b, _ := json.Marshal(cs); string(b) != "[]" {
|
|
t.Fatalf("expected [], got %s", b)
|
|
}
|
|
ps, _ := s.ListProjects("owner_none")
|
|
if ps == nil {
|
|
t.Fatal("ListProjects returned nil slice")
|
|
}
|
|
if b, _ := json.Marshal(ps); string(b) != "[]" {
|
|
t.Fatalf("expected [], got %s", b)
|
|
}
|
|
}
|