refactor: share cron delivery test fixture · openclaw/openclaw@abe2145
vincentkoc
·
2026-06-01
·
via Recent Commits to openclaw:main
File tree
src/gateway/server-methods
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 2 | import type { ChannelPlugin } from "../../channels/plugins/types.public.js"; |
3 | 3 | import type { OpenClawConfig } from "../../config/types.openclaw.js"; |
4 | | -import type { CronJob } from "../../cron/types.js"; |
| 4 | +import type { CronDelivery, CronJob } from "../../cron/types.js"; |
5 | 5 | import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../../plugins/runtime.js"; |
6 | 6 | import { |
7 | 7 | createChannelTestPluginBase, |
@@ -153,6 +153,21 @@ function createCronJob(overrides: Partial<CronJob> = {}): CronJob {
|
153 | 153 | }; |
154 | 154 | } |
155 | 155 | |
| 156 | +function telegramDeliveryWithSlackFailure(overrides: Partial<CronDelivery> = {}): CronDelivery { |
| 157 | +return { |
| 158 | +mode: "announce", |
| 159 | +channel: "telegram", |
| 160 | +to: "telegram:123", |
| 161 | +failureDestination: { |
| 162 | +mode: "announce", |
| 163 | +channel: "slack", |
| 164 | +to: "C123", |
| 165 | +accountId: "bot-b", |
| 166 | +}, |
| 167 | + ...overrides, |
| 168 | +}; |
| 169 | +} |
| 170 | + |
156 | 171 | function setRuntimeConfig(config: OpenClawConfig): void { |
157 | 172 | getRuntimeConfig.mockReturnValue(config); |
158 | 173 | } |
@@ -569,19 +584,10 @@ describe("cron method validation", () => {
|
569 | 584 | }, |
570 | 585 | }, |
571 | 586 | createCronJob({ |
572 | | -delivery: { |
573 | | -mode: "announce", |
574 | | -channel: "telegram", |
575 | | -to: "telegram:123", |
| 587 | +delivery: telegramDeliveryWithSlackFailure({ |
576 | 588 | threadId: "99", |
577 | 589 | accountId: "bot-a", |
578 | | -failureDestination: { |
579 | | -mode: "announce", |
580 | | -channel: "slack", |
581 | | -to: "C123", |
582 | | -accountId: "bot-b", |
583 | | -}, |
584 | | -}, |
| 590 | +}), |
585 | 591 | }), |
586 | 592 | ); |
587 | 593 | |
@@ -614,17 +620,7 @@ describe("cron method validation", () => {
|
614 | 620 | }, |
615 | 621 | }, |
616 | 622 | createCronJob({ |
617 | | -delivery: { |
618 | | -mode: "announce", |
619 | | -channel: "telegram", |
620 | | -to: "telegram:123", |
621 | | -failureDestination: { |
622 | | -mode: "announce", |
623 | | -channel: "slack", |
624 | | -to: "C123", |
625 | | -accountId: "bot-b", |
626 | | -}, |
627 | | -}, |
| 623 | +delivery: telegramDeliveryWithSlackFailure(), |
628 | 624 | }), |
629 | 625 | ); |
630 | 626 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。