onesvm-browser-server/server/internal/proxymanager/testhelpers_test.go
chii eb972dfa93 feat: 落地 browser-server 控制面并打通 mgr1 海外订阅
单二进制三角色 + Dock 适配器 + Swarm stack 达到可部署态;mgr1 实测订阅经 central-proxy bootstrap,探活 alive=41/52。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-02 15:05:12 +08:00

31 lines
803 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// testhelpers_test.go:测试辅助(日志缓冲、io 别名、时钟别名、deny 注入)。
package proxymanager
import (
"bytes"
"io"
"log"
"strings"
"time"
)
// timeSecond 时长别名(测试可读性)。
const timeSecond = time.Second
// ioReadAll io.ReadAll 别名。
func ioReadAll(r io.Reader) ([]byte, error) { return io.ReadAll(r) }
// logBuffer 线程安全日志缓冲(脱敏断言用)。
type logBuffer struct {
bytes.Buffer
}
// newBufLogger 构造写缓冲的 logger。
func newBufLogger(buf *logBuffer) *log.Logger {
return log.New(buf, "", 0)
}
// addTestDeny 内存注入 deny 规则(DomainTrie.Insert,与 LoadFromStore 同一插入路径)。
func addTestDeny(m *Manager, suffix string) {
m.rules.Insert("."+strings.TrimPrefix(suffix, "."), "deny")
}