mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-12 02:09:42 +08:00
* feat(http-tunnel): 支持独立 HTTP 隧道连接并覆盖多数据源 refs #168 * fix(kingbase-data-grid): 修复金仓打开表卡顿并降低对象渲染开销 refs #178 * fix(kingbase-transaction): 修复金仓事务提交重复引号导致语法错误 refs #176 * fix(driver-agent): 修复老版本 Win10 升级后金仓驱动代理启动失败 refs #177 * chore(ci): 新增手动触发的 macOS 测试构建工作流 * chore(ci): 允许测试工作流在当前分支自动触发 * fix(query-editor): 修复 SQL 编辑中光标随机跳到末尾 refs #185 * feat(data-sync): 增加差异 SQL 预览能力便于审核 refs #174 * fix(clickhouse-connect): 自动识别并回退 HTTP/Native 协议连接 refs #181 * fix(oracle-metadata): 修复视图与函数加载按 schema 过滤异常 refs #155 * fix(dameng-databases): 修复显示全部库时数据库列表不完整 refs #154 * fix(connection,db-list): 统一处理空列表返回并修复达梦连接测试报错 refs #157 Co-authored-by: 辣条 <69459608+tianqijiuyun-latiao@users.noreply.github.com>
101 lines
2.8 KiB
Go
101 lines
2.8 KiB
Go
package db
|
||
|
||
import (
|
||
"os"
|
||
"path/filepath"
|
||
"runtime"
|
||
"testing"
|
||
)
|
||
|
||
func TestPostgresRuntimeSupportRequiresInstallMarker(t *testing.T) {
|
||
tmpDir := t.TempDir()
|
||
SetExternalDriverDownloadDirectory(tmpDir)
|
||
|
||
supported, _ := DriverRuntimeSupportStatus("postgres")
|
||
if !supported {
|
||
t.Fatalf("postgres 属于免安装内置驱动,应可用")
|
||
}
|
||
supported, reason := DriverRuntimeSupportStatus("postgres")
|
||
if !supported {
|
||
t.Fatalf("postgres 应可用,reason=%s", reason)
|
||
}
|
||
}
|
||
|
||
func TestBuiltinLikeDriversRemainAvailable(t *testing.T) {
|
||
tmpDir := t.TempDir()
|
||
SetExternalDriverDownloadDirectory(tmpDir)
|
||
|
||
supported, reason := DriverRuntimeSupportStatus("redis")
|
||
if !supported {
|
||
t.Fatalf("redis 应始终可用,reason=%s", reason)
|
||
}
|
||
}
|
||
|
||
func TestManagedDriverRequiresInstallMarker(t *testing.T) {
|
||
tmpDir := t.TempDir()
|
||
SetExternalDriverDownloadDirectory(tmpDir)
|
||
|
||
supported, _ := DriverRuntimeSupportStatus("mariadb")
|
||
if supported {
|
||
t.Fatalf("mariadb 未安装时不应可用")
|
||
}
|
||
|
||
if !IsOptionalGoDriverBuildIncluded("mariadb") {
|
||
supported, reason := DriverRuntimeSupportStatus("mariadb")
|
||
if supported {
|
||
t.Fatalf("精简构建下 mariadb 不应可用")
|
||
}
|
||
if reason == "" {
|
||
t.Fatalf("精简构建下 mariadb 应返回不可用原因")
|
||
}
|
||
return
|
||
}
|
||
|
||
markerPath, err := ResolveOptionalGoDriverMarkerPath(tmpDir, "mariadb")
|
||
if err != nil {
|
||
t.Fatalf("解析 marker 路径失败: %v", err)
|
||
}
|
||
if err := os.MkdirAll(filepath.Dir(markerPath), 0o755); err != nil {
|
||
t.Fatalf("创建 marker 目录失败: %v", err)
|
||
}
|
||
if err := os.WriteFile(markerPath, []byte("{}"), 0o644); err != nil {
|
||
t.Fatalf("写入 marker 失败: %v", err)
|
||
}
|
||
executablePath, err := ResolveOptionalDriverAgentExecutablePath(tmpDir, "mariadb")
|
||
if err != nil {
|
||
t.Fatalf("解析 mariadb 代理路径失败: %v", err)
|
||
}
|
||
if runtime.GOOS == "windows" {
|
||
selfPath, selfErr := os.Executable()
|
||
if selfErr != nil {
|
||
t.Fatalf("获取测试进程路径失败: %v", selfErr)
|
||
}
|
||
content, readErr := os.ReadFile(selfPath)
|
||
if readErr != nil {
|
||
t.Fatalf("读取测试进程失败: %v", readErr)
|
||
}
|
||
if err := os.WriteFile(executablePath, content, 0o755); err != nil {
|
||
t.Fatalf("写入 mariadb 代理占位可执行文件失败: %v", err)
|
||
}
|
||
} else {
|
||
if err := os.WriteFile(executablePath, []byte("placeholder"), 0o755); err != nil {
|
||
t.Fatalf("写入 mariadb 代理占位文件失败: %v", err)
|
||
}
|
||
}
|
||
|
||
supported, reason := DriverRuntimeSupportStatus("mariadb")
|
||
if !supported {
|
||
t.Fatalf("mariadb 安装后应可用,reason=%s", reason)
|
||
}
|
||
}
|
||
|
||
func TestMySQLBuiltinRuntimeSupportAvailable(t *testing.T) {
|
||
tmpDir := t.TempDir()
|
||
SetExternalDriverDownloadDirectory(tmpDir)
|
||
|
||
supported, reason := DriverRuntimeSupportStatus("mysql")
|
||
if !supported {
|
||
t.Fatalf("mysql 属于免安装内置驱动,应可用,reason=%s", reason)
|
||
}
|
||
}
|