diff --git a/internal/shortcut/chat/gap_fill_test.go b/internal/shortcut/chat/gap_fill_test.go index c1aaafb2..d2c618b9 100644 --- a/internal/shortcut/chat/gap_fill_test.go +++ b/internal/shortcut/chat/gap_fill_test.go @@ -22,6 +22,14 @@ import ( "github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/shortcut" ) +type chatOutputErrorWriter struct { + err error +} + +func (w chatOutputErrorWriter) Write([]byte) (int, error) { + return 0, w.err +} + func TestCrossPlatformCoverageMessagesSendPublishesCompleteIdentityConstraintInputs(t *testing.T) { want := []string{ "identity", "as", "group", "chat-id", "groups", "groups-file", "chat-query", "user", "user-query", "open-dingtalk-id", @@ -209,6 +217,25 @@ func TestCrossPlatformCoverageMessagesSendBotMultiGroupFailuresReturnNonzero(t * } } +func TestCrossPlatformCoverageMessagesSendBotMultiGroupPropagatesOutputFailure(t *testing.T) { + fake := &larkAlignmentCaller{} + helpers.InitDeps(fake) + wantErr := errors.New("fixture output failed") + root := newPlatformCoverageRoot() + root.SetOut(chatOutputErrorWriter{err: wantErr}) + root.SetArgs([]string{ + "chat", "+messages-send", "--as", "bot", "--robot-code", "robot", + "--groups", "cid-a,cid-b", "--markdown", "通知", "--yes", + }) + + if err := root.Execute(); !errors.Is(err, wantErr) { + t.Fatalf("output error = %v, want %v", err, wantErr) + } + if len(fake.calls) != 2 { + t.Fatalf("multi-group calls = %#v", fake.calls) + } +} + func TestCrossPlatformCoverageMessagesSendBotGroupsFileUsesSafeDeduplicatedTargets(t *testing.T) { t.Chdir(t.TempDir()) if err := os.WriteFile("groups.txt", []byte("# comment\ncid-a,cid-b\ncid-a\n"), 0o600); err != nil {