feat(notify): 重构通信内核并补齐 stream/bulk/record/transfer 能力
- 引入 LogicalConn/TransportConn 分层,ClientConn 保留兼容适配层 - 新增 Stream、Bulk、RecordStream 三条数据面能力及对应控制路径 - 完成 transfer/file 传输内核与状态快照、诊断能力 - 补齐 reconnect、inbound dispatcher、modern psk 等基础模块 - 增加大规模回归、并发与基准测试覆盖 - 更新依赖库
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package notify
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBuildFileIDUniqueAcrossBurst(t *testing.T) {
|
||||
const total = 512
|
||||
seen := make(map[string]struct{}, total)
|
||||
for i := 0; i < total; i++ {
|
||||
id := buildFileID("report.txt")
|
||||
if _, ok := seen[id]; ok {
|
||||
t.Fatalf("duplicate file id generated: %q", id)
|
||||
}
|
||||
seen[id] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildFileIDKeepsReadableBaseName(t *testing.T) {
|
||||
id := buildFileID("/tmp/demo/report.txt")
|
||||
if !strings.HasPrefix(id, "report.txt-") {
|
||||
t.Fatalf("unexpected file id prefix: %q", id)
|
||||
}
|
||||
|
||||
parts := strings.Split(id, "-")
|
||||
if got, want := len(parts), 5; got != want {
|
||||
t.Fatalf("unexpected file id segment count: got %d want %d, id=%q", got, want, id)
|
||||
}
|
||||
for _, part := range parts[1:] {
|
||||
if part == "" {
|
||||
t.Fatalf("unexpected empty file id segment: %q", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildFileIDFallsBackToUnnamedBase(t *testing.T) {
|
||||
id := buildFileID("")
|
||||
if !strings.HasPrefix(id, "unnamed-") {
|
||||
t.Fatalf("unexpected unnamed file id prefix: %q", id)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewFileMetaEnvelopeKeepsOptionalMeta(t *testing.T) {
|
||||
env := newFileMetaEnvelope("file-1", "/tmp/demo/report.txt", 123, "sum", 0o640, 123456789)
|
||||
if got, want := env.File.Mode, uint32(0o640); got != want {
|
||||
t.Fatalf("mode mismatch: got %o want %o", got, want)
|
||||
}
|
||||
if got, want := env.File.ModTime, int64(123456789); got != want {
|
||||
t.Fatalf("modtime mismatch: got %d want %d", got, want)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user