fix(im): clarify messages-send dry-run chat membership#927
Conversation
|
|
📝 WalkthroughWalkthroughImMessagesSend.DryRun now warns users that dry-run validates request shape only and does not verify bot/user membership in the target chat. A test sub-case validates the warning appears in output when using --chat-id with --text. ChangesDry-run membership verification warning
🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
shortcuts/im/builders_test.go (1)
732-742: ⚡ Quick winConsider adding a negative test case for user-id sends.
The test correctly validates that the membership warning appears for
--chat-idsends. For completeness, consider adding a companion test case that verifies the warning does NOT appear when using--user-id(since DM sends don't have chat membership semantics).📋 Example negative test case
t.Run("ImMessagesSend dry run does not warn for user-id sends", func(t *testing.T) { runtime := newTestRuntimeContext(t, map[string]string{ "user-id": "ou_123", "text": "hello", }, nil) got := mustMarshalDryRun(t, ImMessagesSend.DryRun(context.Background(), runtime)) if strings.Contains(got, "does not verify that the selected bot/user is a member") { t.Fatalf("ImMessagesSend.DryRun() should not warn about membership for user-id sends: %s", got) } })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@shortcuts/im/builders_test.go` around lines 732 - 742, Add a negative test alongside the existing "ImMessagesSend dry run warns chat membership is not verified" that constructs a runtime via newTestRuntimeContext with "user-id" (e.g., "ou_123") and "text", calls ImMessagesSend.DryRun(context.Background(), runtime), marshals the result with mustMarshalDryRun, and asserts that the membership warning string (e.g., "does not verify that the selected bot/user is a member") is NOT present; reference ImMessagesSend.DryRun, newTestRuntimeContext, and mustMarshalDryRun to locate where to add this test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@shortcuts/im/builders_test.go`:
- Around line 732-742: Add a negative test alongside the existing
"ImMessagesSend dry run warns chat membership is not verified" that constructs a
runtime via newTestRuntimeContext with "user-id" (e.g., "ou_123") and "text",
calls ImMessagesSend.DryRun(context.Background(), runtime), marshals the result
with mustMarshalDryRun, and asserts that the membership warning string (e.g.,
"does not verify that the selected bot/user is a member") is NOT present;
reference ImMessagesSend.DryRun, newTestRuntimeContext, and mustMarshalDryRun to
locate where to add this test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 81a08a86-848f-4e83-9e1c-ca5083df277b
📒 Files selected for processing (2)
shortcuts/im/builders_test.goshortcuts/im/im_messages_send.go
Summary
Clarify that
im +messages-send --dry-runvalidates request shape only and does not prove the selected bot/user can send to the target chat.Changes
Test Plan
go test ./shortcuts/im -run 'TestShortcutDryRunShapes/ImMessagesSend_dry_run_warns_chat_membership_is_not_verified' -count=1go test ./shortcuts/im -run 'TestShortcutDryRunShapes' -count=1go test ./shortcuts/im -run 'TestImMessagesSend|TestShortcutDryRunShapes' -count=1gofmt -l shortcuts/im/im_messages_send.go shortcuts/im/builders_test.gogit diff --check -- shortcuts/im/im_messages_send.go shortcuts/im/builders_test.gogo test ./shortcuts/im -count=1was run locally on Windows but is blocked by existing media/path tests unrelated to this change (TestParseMediaDurationSuccess,TestNormalizeDownloadOutputPath,TestResolveIMResourceDownloadPath,TestValidateMediaFlagPath).Related Issues
Summary by CodeRabbit