mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
- Move all source files to internal/{app,backend,config,executor,logger,parser,utils}
- Integrate third-party libraries: zerolog, goccy/go-json, gopsutil, cobra/viper
- Add comprehensive unit tests for utils package (94.3% coverage)
- Add performance benchmarks for string operations
- Fix error display: cleanup warnings no longer pollute Recent Errors
- Add GitHub Actions CI workflow
- Add Makefile for build automation
- Add README documentation
Generated with SWE-Agent.ai
Co-Authored-By: SWE-Agent.ai <noreply@swe-agent.ai>
32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
package parser
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestParseJSONStream_SkipsOverlongLineAndContinues(t *testing.T) {
|
|
// Exceed the 10MB bufio.Scanner limit in parseJSONStreamInternal.
|
|
tooLong := strings.Repeat("a", 11*1024*1024)
|
|
|
|
input := strings.Join([]string{
|
|
`{"type":"item.completed","item":{"type":"other_type","text":"` + tooLong + `"}}`,
|
|
`{"type":"thread.started","thread_id":"t-1"}`,
|
|
`{"type":"item.completed","item":{"type":"agent_message","text":"ok"}}`,
|
|
}, "\n")
|
|
|
|
var warns []string
|
|
warnFn := func(msg string) { warns = append(warns, msg) }
|
|
|
|
gotMessage, gotThreadID := ParseJSONStreamInternal(strings.NewReader(input), warnFn, nil, nil, nil)
|
|
if gotMessage != "ok" {
|
|
t.Fatalf("message=%q, want %q (warns=%v)", gotMessage, "ok", warns)
|
|
}
|
|
if gotThreadID != "t-1" {
|
|
t.Fatalf("threadID=%q, want %q (warns=%v)", gotThreadID, "t-1", warns)
|
|
}
|
|
if len(warns) == 0 || !strings.Contains(warns[0], "Skipped overlong JSON line") {
|
|
t.Fatalf("expected warning about overlong JSON line, got %v", warns)
|
|
}
|
|
}
|