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>
37 lines
773 B
Go
37 lines
773 B
Go
package executor
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestLogWriterWriteLimitsBuffer(t *testing.T) {
|
|
logger, err := NewLogger()
|
|
if err != nil {
|
|
t.Fatalf("NewLogger error: %v", err)
|
|
}
|
|
setLogger(logger)
|
|
t.Cleanup(func() { _ = closeLogger() })
|
|
|
|
lw := newLogWriter("P:", 10)
|
|
_, _ = lw.Write([]byte(strings.Repeat("a", 100)))
|
|
|
|
if lw.buf.Len() != 10 {
|
|
t.Fatalf("logWriter buffer len=%d, want %d", lw.buf.Len(), 10)
|
|
}
|
|
if !lw.dropped {
|
|
t.Fatalf("expected logWriter to drop overlong line bytes")
|
|
}
|
|
|
|
lw.Flush()
|
|
logger.Flush()
|
|
data, err := os.ReadFile(logger.Path())
|
|
if err != nil {
|
|
t.Fatalf("ReadFile error: %v", err)
|
|
}
|
|
if !strings.Contains(string(data), "P:aaaaaaa...") {
|
|
t.Fatalf("log output missing truncated entry, got %q", string(data))
|
|
}
|
|
}
|