mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-16 19:49:51 +08:00
✨ feat(query-editor): 支持查询重命名导出与保存快捷键
- 支持已保存查询重命名并同步当前标签标题 - 新增 SQL 文件导出接口、Wails 绑定和浏览器 mock - 补充 Ctrl/Cmd+S 保存查询与 Ctrl+, 快捷键入口修复 - 覆盖 SQL 编辑器保存、导出和快捷键回归测试
This commit is contained in:
@@ -75,6 +75,45 @@ func TestWriteSQLFileByPathRejectsEmptyPath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeSQLExportDefaultFilename(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
raw string
|
||||
want string
|
||||
}{
|
||||
{name: "blank", raw: " ", want: "query.sql"},
|
||||
{name: "appends extension", raw: "daily report", want: "daily report.sql"},
|
||||
{name: "keeps sql extension", raw: "report.SQL", want: "report.SQL"},
|
||||
{name: "uses base name", raw: filepath.Join("folder", "report.sql"), want: "report.sql"},
|
||||
{name: "replaces invalid chars", raw: `a:b*c?d"e<f>g|h`, want: "a_b_c_d_e_f_g_h.sql"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := normalizeSQLExportDefaultFilename(tt.raw); got != tt.want {
|
||||
t.Fatalf("expected %q, got %q", tt.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteExportedSQLFileByPathCreatesNewSQLFile(t *testing.T) {
|
||||
filePath := filepath.Join(t.TempDir(), "exported")
|
||||
|
||||
result := writeExportedSQLFileByPath(filePath, "select 42;\n")
|
||||
if !result.Success {
|
||||
t.Fatalf("expected sql export to succeed, got %#v", result)
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(filePath + ".sql")
|
||||
if err != nil {
|
||||
t.Fatalf("ReadFile returned error: %v", err)
|
||||
}
|
||||
if string(data) != "select 42;\n" {
|
||||
t.Fatalf("expected exported sql content, got %q", string(data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadSQLFileByPathReturnsLargeFileMetadata(t *testing.T) {
|
||||
filePath := filepath.Join(t.TempDir(), "big.sql")
|
||||
file, err := os.Create(filePath)
|
||||
|
||||
Reference in New Issue
Block a user