- CHANGELOG.md:v2.8.0 条目(中英双语); - README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明); - doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制); - skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/ require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过); - 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
42 lines
1.0 KiB
Go
Executable File
42 lines
1.0 KiB
Go
Executable File
package httpx
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestDrainForwardReadsIncrementalLines(t *testing.T) {
|
|
dir := t.TempDir()
|
|
path := filepath.Join(dir, "evt.ndjson")
|
|
if err := os.WriteFile(path, []byte("{\"type\":\"a\"}\n{\"type\":\"b\"}\n"), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var lines []string
|
|
off := drainForward(path, 0, func(line string) {
|
|
lines = append(lines, line)
|
|
})
|
|
if len(lines) != 2 {
|
|
t.Fatalf("got %d lines %#v", len(lines), lines)
|
|
}
|
|
if off <= 0 {
|
|
t.Fatalf("offset=%d", off)
|
|
}
|
|
// Append after first drain — second call with offset must only see new line.
|
|
f, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0o600)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := f.WriteString("{\"type\":\"c\"}\n"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_ = f.Close()
|
|
var more []string
|
|
off2 := drainForward(path, off, func(line string) {
|
|
more = append(more, line)
|
|
})
|
|
if len(more) != 1 || more[0] != "{\"type\":\"c\"}" {
|
|
t.Fatalf("incremental got %#v off=%d→%d", more, off, off2)
|
|
}
|
|
}
|