阶段六:收口Automation发货卡密与通知动作边界
This commit is contained in:
1 parent
9255eb3132
commit
e5df708e4a
6 files changed
+1067
-1226
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package automation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"xianyu-go/internal/db"
|
||||
)
|
||||
|
||||
// TestAutomationActionExecutorPreservesMessageNotSent 验证动作执行器保留“确定未发送”错误,供运行协调器安全重试。
|
||||
func TestAutomationActionExecutorPreservesMessageNotSent(t *testing.T) {
|
||||
// sender 是返回确定未发送错误的测试发送器。
|
||||
sender := &testSender{err: fmt.Errorf("%w: websocket 尚未就绪", ErrMessageNotSent)}
|
||||
// executor 是仅注入消息发送器的动作执行器。
|
||||
executor := automationActionExecutor{senders: testSenderProvider{sender: sender}}
|
||||
// sent 是动作执行器报告的已发送数量。
|
||||
sent, err := executor.executeAction(context.Background(), Task{
|
||||
AccountID: "cid",
|
||||
ChatID: "chat",
|
||||
BuyerID: "buyer",
|
||||
}, db.AutomationAction{ActionType: ActionSendText, MessageTemplate: "hello"})
|
||||
if sent != 0 || !errors.Is(err, ErrMessageNotSent) {
|
||||
t.Fatalf("确定未发送错误未保留: sent=%d err=%v", sent, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user