11package worker
22
33import (
4+ "strings"
45 "testing"
56
67 "github.com/GrapeInTheTree/pocket-claude/internal/store"
@@ -84,14 +85,11 @@ func TestFormatToolName(t *testing.T) {
8485 {"Edit" , "Edit" , "✏️ File Edit" },
8586 {"Read" , "Read" , "📖 File Read" },
8687 {"unknown tool" , "CustomTool" , "🔧 CustomTool" },
87- // mcp__claude_ai_Slack__slack_send_message splits on "__" to:
88- // ["mcp", "claude_ai_Slack", "slack_send_message"]
89- // service=parts[2]="slack_send_message", action=last="slack_send_message"
90- {"MCP Slack" , "mcp__claude_ai_Slack__slack_send_message" , "🔌 slack_send_message → Slack Send Message" },
91- {"MCP Notion" , "mcp__claude_ai_Notion__notion_search" , "🔌 notion_search → Notion Search" },
92- // mcp__foo__bar__do_thing splits to ["mcp", "foo", "bar", "do_thing"]
93- // service=parts[2]="bar", action=last="do_thing"
94- {"MCP unknown service" , "mcp__foo__bar__do_thing" , "🔌 bar → Do Thing" },
88+ // mcp__claude_ai_Slack__slack_send_message → service="Slack", action="Send Message"
89+ {"MCP Slack" , "mcp__claude_ai_Slack__slack_send_message" , "💬 Slack → Send Message" },
90+ {"MCP Notion" , "mcp__claude_ai_Notion__notion_search" , "📝 Notion → Search" },
91+ // mcp__foo__bar__do_thing → namespace="foo", service="foo", action="do_thing"
92+ {"MCP unknown service" , "mcp__foo__bar__do_thing" , "🔌 foo → Do Thing" },
9593 }
9694
9795 for _ , tt := range tests {
@@ -109,11 +107,11 @@ func TestBuildPermissionMessage(t *testing.T) {
109107 PermissionDenials : []store.PermissionDenial {
110108 {
111109 ToolName : "Bash" ,
112- ToolInput : map [string ]interface {} {"command" : "rm -rf /tmp/test" },
110+ ToolInput : map [string ]any {"command" : "rm -rf /tmp/test" },
113111 },
114112 {
115113 ToolName : "Write" ,
116- ToolInput : map [string ]interface {} {"file_path" : "/home/user/file.txt" },
114+ ToolInput : map [string ]any {"file_path" : "/home/user/file.txt" },
117115 },
118116 },
119117 Result : "I need to run a command" ,
@@ -142,10 +140,10 @@ func TestBuildPermissionMessageDedup(t *testing.T) {
142140 // Multiple denials for the same tool should be grouped
143141 result := & store.CLIResult {
144142 PermissionDenials : []store.PermissionDenial {
145- {ToolName : "Bash" , ToolInput : map [string ]interface {} {"command" : "ls" }},
146- {ToolName : "Bash" , ToolInput : map [string ]interface {} {"command" : "pwd" }},
147- {ToolName : "Bash" , ToolInput : map [string ]interface {} {"command" : "cat file" }},
148- {ToolName : "Bash" , ToolInput : map [string ]interface {} {"command" : "extra" }}, // 4th, should be capped at 3
143+ {ToolName : "Bash" , ToolInput : map [string ]any {"command" : "ls" }},
144+ {ToolName : "Bash" , ToolInput : map [string ]any {"command" : "pwd" }},
145+ {ToolName : "Bash" , ToolInput : map [string ]any {"command" : "cat file" }},
146+ {ToolName : "Bash" , ToolInput : map [string ]any {"command" : "extra" }}, // 4th, should be capped at 3
149147 },
150148 }
151149
@@ -172,14 +170,5 @@ func TestSanitizeUTF8(t *testing.T) {
172170}
173171
174172func contains (s , substr string ) bool {
175- return len (s ) >= len (substr ) && containsSubstr (s , substr )
176- }
177-
178- func containsSubstr (s , substr string ) bool {
179- for i := 0 ; i <= len (s )- len (substr ); i ++ {
180- if s [i :i + len (substr )] == substr {
181- return true
182- }
183- }
184- return false
173+ return strings .Contains (s , substr )
185174}
0 commit comments