feat: 增加商品目录导入记录 (#134)
This commit is contained in:
@@ -3,6 +3,7 @@ package repository
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
_ "modernc.org/sqlite"
|
||||
@@ -49,4 +50,29 @@ func TestCatalogImportRun_登记查询重放和冲突(t *testing.T) {
|
||||
if got.RequestCount != 3 || got.ConflictCount != 1 || got.LastConflictAt == "" {
|
||||
t.Fatalf("批次计数不正确:%+v", got)
|
||||
}
|
||||
other := run
|
||||
other.Source, other.BatchID = "script-b", "batch-2"
|
||||
if err := InsertCatalogImportRun(db, other); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
list, total, err := ListCatalogImportRuns(db, "script-a", model.CatalogImportProcessing, 20, 0)
|
||||
if err != nil || total != 1 || len(list) != 1 || list[0].BatchID != "batch-1" {
|
||||
t.Fatalf("分页筛选错误:total=%d list=%+v err=%v", total, list, err)
|
||||
}
|
||||
sources, err := ListCatalogImportSources(db)
|
||||
if err != nil || len(sources) != 2 {
|
||||
t.Fatalf("来源列表错误:%v %v", sources, err)
|
||||
}
|
||||
for i := 3; i <= 1001; i++ {
|
||||
bulk := run
|
||||
bulk.Source = "script-b"
|
||||
bulk.BatchID = fmt.Sprintf("batch-%04d", i)
|
||||
if err := InsertCatalogImportRun(db, bulk); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
page, total, err := ListCatalogImportRuns(db, "script-b", "", 20, 20)
|
||||
if err != nil || total != 1000 || len(page) != 20 {
|
||||
t.Fatalf("1000 条数据库分页错误:total=%d rows=%d err=%v", total, len(page), err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user