Compare commits

...

1 Commits

Author SHA1 Message Date
core-be 561d5b2be9 test(channels): add 9 cases for matchesChatID
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 16s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 41s
CI / Detect changes (pull_request) Successful in 1m11s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 27s
Harness Replays / detect-changes (pull_request) Successful in 52s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 42s
E2E API Smoke Test / detect-changes (pull_request) Successful in 2m13s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m51s
Harness Replays / Harness Replays (pull_request) Successful in 12s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 2m9s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 11s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m22s
CI / Python Lint & Test (pull_request) Successful in 8m17s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 5m47s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Failing after 10m42s
CI / Canvas (Next.js) (pull_request) Failing after 16m7s
CI / Platform (Go) (pull_request) Failing after 21m8s
CI / all-required (pull_request) Failing after 25m57s
gate-check-v3 / gate-check (pull_request) Has been cancelled
qa-review / approved (pull_request) Has been cancelled
security-review / approved (pull_request) Has been cancelled
CI / Canvas Deploy Reminder (pull_request) Has been cancelled
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Has been cancelled
sop-checklist / all-items-acked (pull_request) Has been cancelled
sop-tier-check / tier-check (pull_request) Has been cancelled
Covers: empty config, missing key, empty value, exact match,
no match, multiple IDs one match / no match, whitespace
trim, and trailing comma edge case.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 06:25:16 +00:00
@@ -848,3 +848,62 @@ func TestChannelHandler_Webhook_Discord_ValidSig_PingAccepted(t *testing.T) {
t.Fatalf("unmet sqlmock expectations: %v", err)
}
}
// ==================== matchesChatID (pure helper) ====================
func TestMatchesChatID_EmptyConfig(t *testing.T) {
if matchesChatID(map[string]interface{}{}, "12345") {
t.Error("empty config should return false")
}
}
func TestMatchesChatID_MissingChatIDKey(t *testing.T) {
if matchesChatID(map[string]interface{}{"foo": "bar"}, "12345") {
t.Error("missing chat_id key should return false")
}
}
func TestMatchesChatID_EmptyChatIDValue(t *testing.T) {
if matchesChatID(map[string]interface{}{"chat_id": ""}, "12345") {
t.Error("empty chat_id value should return false")
}
}
func TestMatchesChatID_ExactMatch(t *testing.T) {
if !matchesChatID(map[string]interface{}{"chat_id": "12345"}, "12345") {
t.Error("exact match should return true")
}
}
func TestMatchesChatID_NoMatch(t *testing.T) {
if matchesChatID(map[string]interface{}{"chat_id": "12345"}, "67890") {
t.Error("no match should return false")
}
}
func TestMatchesChatID_MultipleIDsOneMatch(t *testing.T) {
if !matchesChatID(map[string]interface{}{"chat_id": "111,222,333"}, "222") {
t.Error("middle ID should match")
}
}
func TestMatchesChatID_MultipleIDsNoMatch(t *testing.T) {
if matchesChatID(map[string]interface{}{"chat_id": "111,222,333"}, "444") {
t.Error("none of multiple IDs match → false")
}
}
func TestMatchesChatID_WhitespaceTrimmed(t *testing.T) {
if !matchesChatID(map[string]interface{}{"chat_id": " 111 , 222 , 333 "}, "222") {
t.Error("whitespace around ID should be trimmed before match")
}
if matchesChatID(map[string]interface{}{"chat_id": " 111 , 222 , 333 "}, " 222 ") {
t.Error("search string is not trimmed; no match expected")
}
}
func TestMatchesChatID_TrailingComma(t *testing.T) {
if !matchesChatID(map[string]interface{}{"chat_id": "12345,"}, "12345") {
t.Error("single ID with trailing comma should still match")
}
}