fix: align business reports and record task migration progress
This commit is contained in:
@@ -2,6 +2,9 @@ package business
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"kra/pkg/task"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -77,6 +80,28 @@ func TestReportBuildIdentityRulesAndAnonymousLogins(t *testing.T) {
|
||||
|
||||
type reportBuildFake struct{ days []string }
|
||||
|
||||
type failingReportCommit struct{}
|
||||
|
||||
func (failingReportCommit) Rebuild(_ context.Context, _ ReportBuildKind, _ time.Time, compile func(*ReportInput) ([]*ReportBuiltRow, error)) error {
|
||||
_, err := compile(&ReportInput{Registers: []ReportEvent{{SourceDB: "lx", UserID: reportPtr(1), PromoteID: reportPtr(1), GameID: reportPtr(1)}}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return errors.New("commit failed")
|
||||
}
|
||||
|
||||
func TestReportBuildDetailsDoNotClaimRolledBackRows(t *testing.T) {
|
||||
ctx, output := task.WithOutput(context.Background())
|
||||
uc := NewReportBuildUsecase(failingReportCommit{})
|
||||
if err := uc.Run(ctx, DailyReport, "backfill", "2026-11-03", "2026-11-03"); err == nil {
|
||||
t.Fatal("commit error was lost")
|
||||
}
|
||||
text := output.String()
|
||||
if !strings.Contains(text, "2026-11-03 未提交") || !strings.Contains(text, "已提交日期=0;汇总行=0;身份键=0") {
|
||||
t.Fatalf("rollback was reported as success: %s", text)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *reportBuildFake) Rebuild(_ context.Context, _ ReportBuildKind, day time.Time, _ func(*ReportInput) ([]*ReportBuiltRow, error)) error {
|
||||
r.days = append(r.days, day.Format("2006-01-02"))
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user