onesvm-browser-server/server/internal/policy/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

36 lines
941 B
Go
Raw Permalink 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:policy 测试辅助(SQLite 测试库 + trie 插入便捷方法)。
package policy
import (
"net/http"
"path/filepath"
"testing"
"time"
_ "modernc.org/sqlite" // sqlite driver(policy 测试库)
"onesvm.com/onesvm/browser-server/internal/store"
)
func openPolicyDB(t *testing.T) *store.DB {
t.Helper()
db, err := store.Open(filepath.Join(t.TempDir(), "p.db"))
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { db.Close() })
if err := db.Migrate(); err != nil {
t.Fatal(err)
}
return db
}
// insertStub 测试便捷插入(调用正式版 DomainTrie.Insert,见 domainrules.go)。
func (t *DomainTrie) insertStub() error {
t.Insert(".example.com", ActionDirect)
return nil
}
// robotsTimeoutAnchor 锚点:robots 拉取超时上界(防误改)。
var robotsTimeoutAnchor = 10 * time.Second
var _ = http.DefaultClient // 锚点:net/http 依赖保留(RobotsChecker 使用)