chore: 并入 iotlcm-worker-svr 历史到 worker-svr/(原提交 96f0f4e)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package batch
|
||||
|
||||
import (
|
||||
"context"
|
||||
batchdomain "git.5iot.com/iotlcm-public/iotlcm-worker-svr/internal/batch"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-worker-svr/internal/dao"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-worker-svr/internal/model/do"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExecutionPreservesOriginMetadata(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
r := newTestRepository(t, ctx)
|
||||
insertBatch(t, ctx, r.db, "META", batchdomain.Type103)
|
||||
if _, err := r.db.Model(dao.BatchMain.Table()).Ctx(ctx).Where("batch_no", "META").Data(do.BatchMain{SourceChannel: "mini_program", ExecutionMode: 1}).Update(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if claimed, err := r.MarkProcessing(ctx, "META", batchdomain.Type103); err != nil || !claimed {
|
||||
t.Fatal(claimed, err)
|
||||
}
|
||||
if marked, err := r.MarkFailed(ctx, "META", batchdomain.Type103, "test failure"); err != nil || !marked {
|
||||
t.Fatal(marked, err)
|
||||
}
|
||||
main, err := r.FindMain(ctx, "META")
|
||||
if err != nil || main.SourceChannel != "mini_program" || main.ExecutionMode != 1 {
|
||||
t.Fatalf("metadata changed: %+v err=%v", main, err)
|
||||
}
|
||||
if marked, err := r.MarkFailed(ctx, "META", batchdomain.Type103, "duplicate"); err != nil || marked {
|
||||
t.Fatal(marked, err)
|
||||
}
|
||||
main, err = r.FindMain(ctx, "META")
|
||||
if err != nil || main.SourceChannel != "mini_program" || main.ExecutionMode != 1 {
|
||||
t.Fatal("duplicate mutated origin", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user