更新若干功能
This commit is contained in:
17
sync_test.go
17
sync_test.go
@@ -16,11 +16,8 @@ func newSyncTestApp(t *testing.T) *App {
|
||||
}
|
||||
t.Cleanup(func() { s.db.Close() })
|
||||
// 显式指向本机未监听端口,让远端访问立即失败(离线语义):
|
||||
// 空配置会回落到内置默认服务器,单测可能误连开发机上的真实 MySQL。
|
||||
_ = s.SetMeta("sync_host", "127.0.0.1")
|
||||
_ = s.SetMeta("sync_port", "1")
|
||||
_ = s.SetMeta("sync_user", "test")
|
||||
_ = s.SetMeta("sync_database", "test")
|
||||
// 空配置会回落到打包默认 API,单测可能误连开发机上的真实服务。
|
||||
_ = s.SetMeta("sync_base_url", "http://127.0.0.1:1")
|
||||
return &App{store: s}
|
||||
}
|
||||
|
||||
@@ -137,19 +134,13 @@ func TestApplyRemoteNoteMerge(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSyncConfigHelpers(t *testing.T) {
|
||||
if syncConfigComplete(SyncConfig{Host: "h", User: "u"}) {
|
||||
if syncConfigComplete(SyncConfig{}) {
|
||||
t.Fatal("incomplete config accepted")
|
||||
}
|
||||
c := SyncConfig{Host: "db.local", Port: 3307, User: "root", Password: "pw", Database: "cc"}
|
||||
c := SyncConfig{BaseURL: "http://api.example:8788"}
|
||||
if !syncConfigComplete(c) {
|
||||
t.Fatal("complete config rejected")
|
||||
}
|
||||
dsn := syncDSN(c)
|
||||
for _, want := range []string{"db.local:3307", "root:pw@", "/cc", "charset=utf8mb4"} {
|
||||
if !strings.Contains(dsn, want) {
|
||||
t.Fatalf("dsn %q missing %q", dsn, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 机器码同步:项目身份 / 机器路径分离 ----------
|
||||
|
||||
Reference in New Issue
Block a user