fix: stop enqueueing disabled external table exports

This commit is contained in:
姚章浩
2026-08-13 14:49:44 +08:00
parent 0f30f8cec8
commit e5be9ee780
5 changed files with 42 additions and 10 deletions
@@ -59,9 +59,12 @@ func TestShouldEnqueueQuestionTableExportOnlyForDingTalkSucceededAnswers(t *test
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
if got := shouldEnqueueQuestionTableExport(tc.turn); got != tc.want {
if got := shouldEnqueueQuestionTableExport(tc.turn, true); got != tc.want {
t.Fatalf("shouldEnqueueQuestionTableExport()=%v, want %v", got, tc.want)
}
if got := shouldEnqueueQuestionTableExport(tc.turn, false); got {
t.Fatal("disabled question-table export must not enqueue")
}
})
}
}
@@ -188,8 +191,8 @@ func TestFinishTurnOutboxGuardedByShouldCreateAnswerMessage(t *testing.T) {
if !strings.Contains(guardBlock, "question_table_exports") {
t.Error("question_table_exports INSERT must be inside the shouldCreateAnswerMessage guard block")
}
if !strings.Contains(guardBlock, "if shouldEnqueueQuestionTableExport(turn) {") {
t.Error("question_table_exports INSERT must be guarded to DingTalk turns explicitly")
if !strings.Contains(guardBlock, "if shouldEnqueueQuestionTableExport(turn, s.questionTableExportEnabled) {") {
t.Error("question_table_exports INSERT must require both runtime enablement and a DingTalk turn")
}
// The guard block must be the one that contains the messages INSERT