mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-12 02:39:42 +08:00
- 统一 DuckDB 文件库与 Parquet 文件接入能力 - 补充 URI、文件选择、只读挂载与连接缓存键处理 - 去掉数据源卡片点击前的同步驱动查询,修复打开卡顿 - refs #166
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package app
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"GoNavi-Wails/internal/connection"
|
|
)
|
|
|
|
func TestGetCacheKey_IgnoreTimeout(t *testing.T) {
|
|
base := connection.ConnectionConfig{
|
|
Type: "duckdb",
|
|
Host: `C:\data\songs.duckdb`,
|
|
Timeout: 30,
|
|
UseProxy: false,
|
|
UseSSH: false,
|
|
}
|
|
modified := base
|
|
modified.Timeout = 120
|
|
|
|
left := getCacheKey(base)
|
|
right := getCacheKey(modified)
|
|
if left != right {
|
|
t.Fatalf("expected same cache key when only timeout differs, got %s vs %s", left, right)
|
|
}
|
|
}
|
|
|
|
func TestGetCacheKey_DuckDBHostAndDatabaseEquivalent(t *testing.T) {
|
|
withHost := connection.ConnectionConfig{
|
|
Type: "duckdb",
|
|
Host: `D:\music\songs.duckdb`,
|
|
}
|
|
withDatabase := connection.ConnectionConfig{
|
|
Type: "duckdb",
|
|
Database: `D:\music\songs.duckdb`,
|
|
}
|
|
|
|
left := getCacheKey(withHost)
|
|
right := getCacheKey(withDatabase)
|
|
if left != right {
|
|
t.Fatalf("expected same cache key for duckdb host/database path, got %s vs %s", left, right)
|
|
}
|
|
}
|
|
|
|
func TestGetCacheKey_KeepDatabaseIsolation(t *testing.T) {
|
|
a := connection.ConnectionConfig{
|
|
Type: "mysql",
|
|
Host: "127.0.0.1",
|
|
Port: 3306,
|
|
User: "root",
|
|
Password: "root",
|
|
Database: "db_a",
|
|
Timeout: 30,
|
|
}
|
|
b := a
|
|
b.Database = "db_b"
|
|
b.Timeout = 5
|
|
|
|
left := getCacheKey(a)
|
|
right := getCacheKey(b)
|
|
if left == right {
|
|
t.Fatalf("expected different cache key for different database targets")
|
|
}
|
|
}
|