mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-28 09:21:38 +08:00
- 新增共享六语言词典、前端 i18n 运行时与语言设置入口 - 推进连接、驱动、数据网格、查询、AI、Redis、表设计等模块文案本地化 - 补充 raw 边界、SQL/驱动/更新场景测试与 i18n 扫描工具
76 lines
2.4 KiB
Go
76 lines
2.4 KiB
Go
package app
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestValidateLocalDriverPackagePathRejectsJdbcJar(t *testing.T) {
|
|
err := validateLocalDriverPackagePath(filepath.Join("tmp", "kingbase8.JAR"))
|
|
if err == nil {
|
|
t.Fatal("expected JDBC jar path to be rejected")
|
|
}
|
|
if !strings.Contains(err.Error(), "JDBC Jar") {
|
|
t.Fatalf("expected JDBC jar hint, got %q", err.Error())
|
|
}
|
|
if err := validateLocalDriverPackagePath(filepath.Join("tmp", "kingbase-driver-agent.zip")); err != nil {
|
|
t.Fatalf("expected zip package to stay supported, got %v", err)
|
|
}
|
|
}
|
|
|
|
func TestInstallLocalDriverPackageRejectsJdbcJarBeforeBuildChecks(t *testing.T) {
|
|
jarPath := filepath.Join(t.TempDir(), "kingbase8.jar")
|
|
if err := os.WriteFile(jarPath, []byte("fake-jar"), 0o644); err != nil {
|
|
t.Fatalf("write temp jar: %v", err)
|
|
}
|
|
|
|
app := &App{}
|
|
result := app.InstallLocalDriverPackage("kingbase", jarPath, t.TempDir(), "")
|
|
if result.Success {
|
|
t.Fatal("expected local jar import to fail")
|
|
}
|
|
if !strings.Contains(result.Message, "JDBC Jar") {
|
|
t.Fatalf("expected JDBC jar guidance, got %q", result.Message)
|
|
}
|
|
}
|
|
|
|
func TestInstallLocalDriverPackageUsesCurrentLanguageForJdbcJarWrapper(t *testing.T) {
|
|
jarPath := filepath.Join(t.TempDir(), "kingbase8.jar")
|
|
if err := os.WriteFile(jarPath, []byte("fake-jar"), 0o644); err != nil {
|
|
t.Fatalf("write temp jar: %v", err)
|
|
}
|
|
|
|
app := NewApp()
|
|
app.SetLanguage("en-US")
|
|
|
|
result := app.InstallLocalDriverPackage("kingbase", jarPath, t.TempDir(), "")
|
|
if result.Success {
|
|
t.Fatal("expected local jar import to fail")
|
|
}
|
|
if !strings.Contains(result.Message, "Importing JDBC Jar files directly is not supported.") {
|
|
t.Fatalf("expected English JDBC jar guidance, got %q", result.Message)
|
|
}
|
|
if strings.Contains(result.Message, "当前驱动管理不支持直接导入 JDBC Jar") {
|
|
t.Fatalf("expected localized wrapper instead of fixed Chinese, got %q", result.Message)
|
|
}
|
|
}
|
|
|
|
func TestDriverOperationFailureDetailUsesCurrentLanguageForLogHint(t *testing.T) {
|
|
app := NewApp()
|
|
app.SetLanguage("en-US")
|
|
|
|
text := app.driverOperationErrorMessage(errors.New("boom"), "test driver error")
|
|
if !strings.Contains(text, "boom") {
|
|
t.Fatalf("expected raw detail in localized message, got %q", text)
|
|
}
|
|
if !strings.Contains(text, "detail log:") {
|
|
t.Fatalf("expected English log hint, got %q", text)
|
|
}
|
|
if strings.Contains(text, "详细日志") {
|
|
t.Fatalf("expected no Chinese log hint in en-US message, got %q", text)
|
|
}
|
|
}
|