mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-06 02:34:09 +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>
33 lines
838 B
Go
33 lines
838 B
Go
package parser
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestBackendParseJSONStream_UnknownEventsAreSilent(t *testing.T) {
|
|
input := strings.Join([]string{
|
|
`{"type":"turn.started"}`,
|
|
`{"type":"assistant","text":"hi"}`,
|
|
`{"type":"user","text":"yo"}`,
|
|
`{"type":"item.completed","item":{"type":"agent_message","text":"ok"}}`,
|
|
}, "\n")
|
|
|
|
var infos []string
|
|
infoFn := func(msg string) { infos = append(infos, msg) }
|
|
|
|
message, threadID := ParseJSONStreamInternal(strings.NewReader(input), nil, infoFn, nil, nil)
|
|
if message != "ok" {
|
|
t.Fatalf("message=%q, want %q (infos=%v)", message, "ok", infos)
|
|
}
|
|
if threadID != "" {
|
|
t.Fatalf("threadID=%q, want empty (infos=%v)", threadID, infos)
|
|
}
|
|
|
|
for _, msg := range infos {
|
|
if strings.Contains(msg, "Agent event:") {
|
|
t.Fatalf("unexpected log for unknown event: %q", msg)
|
|
}
|
|
}
|
|
}
|