mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-15 11:14:31 +08:00
- SQL、CSV、JSON 与 XLSX 改为资源受限的流式解析,并支持压缩、编码和方言预检 - 增加遇错停止/继续策略、持久任务、错误行导出、源文件身份与安全取消 - 为数据库驱动补齐上下文事务和写入结果未知语义,避免失败重放与脏会话复用
39 lines
1.4 KiB
Go
39 lines
1.4 KiB
Go
package app
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestSQLFileStatementSnippetRedactsDataLiterals(t *testing.T) {
|
|
got := sqlFileStatementSnippet("INSERT INTO users(email, token) VALUES ('alice@example.com', 'secret-token-123')", 200)
|
|
for _, secret := range []string{"alice@example.com", "secret-token-123"} {
|
|
if strings.Contains(got, secret) {
|
|
t.Fatalf("statement snippet leaked %q: %s", secret, got)
|
|
}
|
|
}
|
|
if !strings.Contains(got, "?") {
|
|
t.Fatalf("redacted snippet should retain diagnostic structure: %s", got)
|
|
}
|
|
}
|
|
|
|
func TestSQLFileErrorDetailRedactsDriverValues(t *testing.T) {
|
|
got := sanitizeSQLFileExecutionError("duplicate key value is (alice@example.com); password=secret-token-123")
|
|
for _, secret := range []string{"alice@example.com", "secret-token-123"} {
|
|
if strings.Contains(got, secret) {
|
|
t.Fatalf("driver error leaked %q: %s", secret, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSQLFileExecutionPayloadCarriesStructuredOutcome(t *testing.T) {
|
|
cancelled := buildSQLFileExecutionPayload(12, 1, "cancelled")
|
|
if cancelled["outcome"] != "cancelled" || cancelled["cancelled"] != true || cancelled["completed"] != false {
|
|
t.Fatalf("unexpected cancelled payload: %#v", cancelled)
|
|
}
|
|
partial := buildSQLFileExecutionPayload(12, 1, "partial")
|
|
if partial["outcome"] != "partial" || partial["completed"] != true || partial["stoppedOnError"] != false {
|
|
t.Fatalf("unexpected partial payload: %#v", partial)
|
|
}
|
|
}
|