mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-22 08:50:17 +08:00
- 后端新增 IRIS 连接、查询、DDL、索引元数据和 DataGrid 编辑能力 - 接入 optional driver-agent、构建标签、revision 生成和变更检测流程 - 前端新增 IRIS 连接入口、方言映射、能力配置和图标展示 - 修复 IRIS 主键识别、事务开启错误处理和驱动连接关闭问题 - 补充后端、前端和构建脚本相关回归测试 Refs #408
155 lines
4.5 KiB
Go
155 lines
4.5 KiB
Go
package app
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"GoNavi-Wails/internal/connection"
|
|
)
|
|
|
|
func TestNormalizeSchemaAndTable_SQLServerKeepsDatabaseAndQualifiedTable(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schemaOrDb, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "sqlserver",
|
|
Database: "master",
|
|
}, "biz_db", "dbo.users")
|
|
|
|
if schemaOrDb != "biz_db" {
|
|
t.Fatalf("expected sqlserver first return value as database name, got %q", schemaOrDb)
|
|
}
|
|
if table != "dbo.users" {
|
|
t.Fatalf("expected sqlserver table name keep qualified form, got %q", table)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSchemaAndTable_SQLServerFallbackToConfigDatabase(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schemaOrDb, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "sqlserver",
|
|
Database: "biz_db",
|
|
}, "", "dbo.users")
|
|
|
|
if schemaOrDb != "biz_db" {
|
|
t.Fatalf("expected sqlserver fallback database from config, got %q", schemaOrDb)
|
|
}
|
|
if table != "dbo.users" {
|
|
t.Fatalf("expected sqlserver table name keep qualified form, got %q", table)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSchemaAndTable_PostgresStillSplitsQualifiedName(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schema, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "postgres",
|
|
}, "demo_db", "public.orders")
|
|
|
|
if schema != "public" || table != "orders" {
|
|
t.Fatalf("expected postgres qualified split to public.orders, got %q.%q", schema, table)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSchemaAndTable_KingbaseNormalizesEscapedQualifiedName(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schema, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "kingbase",
|
|
}, "demo_db", `\"Idf_server\".\"mes_bip_wip_finished\"`)
|
|
|
|
if schema != "Idf_server" || table != "mes_bip_wip_finished" {
|
|
t.Fatalf("expected kingbase qualified split to Idf_server.mes_bip_wip_finished, got %q.%q", schema, table)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeRunConfig_OceanBaseOracleKeepsServiceName(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
config := connection.ConnectionConfig{
|
|
Type: "oceanbase",
|
|
Database: "OBORCL",
|
|
OceanBaseProtocol: "oracle",
|
|
}
|
|
runConfig := normalizeRunConfig(config, "SYS")
|
|
|
|
if runConfig.Database != "OBORCL" {
|
|
t.Fatalf("expected OceanBase Oracle service name to stay OBORCL, got %q", runConfig.Database)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeRunConfig_StarRocksUsesDatabaseFromTree(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
runConfig := normalizeRunConfig(connection.ConnectionConfig{
|
|
Type: "starrocks",
|
|
Database: "default_cluster",
|
|
}, "analytics")
|
|
|
|
if runConfig.Database != "analytics" {
|
|
t.Fatalf("expected StarRocks database from tree, got %q", runConfig.Database)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeRunConfig_IRISUsesNamespaceFromTree(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
runConfig := normalizeRunConfig(connection.ConnectionConfig{
|
|
Type: "iris",
|
|
Database: "USER",
|
|
}, "APP")
|
|
|
|
if runConfig.Database != "APP" {
|
|
t.Fatalf("expected IRIS namespace from tree, got %q", runConfig.Database)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSchemaAndTable_IRISDoesNotTreatNamespaceAsSchema(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schema, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "iris",
|
|
}, "USER", "Person")
|
|
|
|
if schema != "" || table != "Person" {
|
|
t.Fatalf("expected IRIS pure table to omit schema, got %q.%q", schema, table)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSchemaAndTable_IRISSplitsQualifiedTable(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schema, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "iris",
|
|
}, "USER", `"Sample.Schema"."Person.Table"`)
|
|
|
|
if schema != "Sample.Schema" || table != "Person.Table" {
|
|
t.Fatalf("expected IRIS qualified table split, got %q.%q", schema, table)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSchemaAndTable_OceanBaseOracleUsesSchemaFromDatabaseTree(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schema, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "oceanbase",
|
|
OceanBaseProtocol: "oracle",
|
|
}, "SYS", "ORDERS")
|
|
|
|
if schema != "SYS" || table != "ORDERS" {
|
|
t.Fatalf("expected OceanBase Oracle schema/table SYS.ORDERS, got %q.%q", schema, table)
|
|
}
|
|
}
|
|
|
|
func TestQuoteTableIdentByType_KingbaseNormalizesQuotedQualifiedTable(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schema, table := normalizeSchemaAndTableByType("kingbase", "", `\"Idf_server\".\"mes_bip_wip_finished\"`)
|
|
if schema != "Idf_server" || table != "mes_bip_wip_finished" {
|
|
t.Fatalf("expected kingbase qualified split to Idf_server.mes_bip_wip_finished, got %q.%q", schema, table)
|
|
}
|
|
|
|
if got := quoteTableIdentByType("kingbase", schema, table); got != `"Idf_server".mes_bip_wip_finished` {
|
|
t.Fatalf("unexpected kingbase table identifier: %s", got)
|
|
}
|
|
}
|