mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-17 04:14:10 +08:00
- SQL、CSV、JSON 与 XLSX 改为资源受限的流式解析,并支持压缩、编码和方言预检 - 增加遇错停止/继续策略、持久任务、错误行导出、源文件身份与安全取消 - 为数据库驱动补齐上下文事务和写入结果未知语义,避免失败重放与脏会话复用
34 lines
945 B
Go
34 lines
945 B
Go
package app
|
|
|
|
import "testing"
|
|
|
|
func TestManagedImportErrorArtifactPublishesOnlyNonEmptyArtifacts(t *testing.T) {
|
|
app := NewApp()
|
|
app.configDir = t.TempDir()
|
|
|
|
empty, err := app.beginManagedImportErrorArtifact("import-empty")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
emptyResult := importExecutionResult{}
|
|
if err := empty.finish(&emptyResult); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if emptyResult.ErrorArtifactID != "" {
|
|
t.Fatalf("empty artifact was published: %#v", emptyResult)
|
|
}
|
|
|
|
failed, err := app.beginManagedImportErrorArtifact("import-failed")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
failed.append(ImportRowError{SourceRow: 2, Category: "database", Message: "duplicate key"})
|
|
failedResult := importExecutionResult{Failed: 1}
|
|
if err := failed.finish(&failedResult); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if failedResult.ErrorArtifactID == "" || failedResult.ErrorArtifactCount != 1 {
|
|
t.Fatalf("rejected row artifact missing: %#v", failedResult)
|
|
}
|
|
}
|