think_test.go
1 package tools 2 3 import ( 4 "context" 5 "testing" 6 ) 7 8 func TestThinkTool_ReturnsThought(t *testing.T) { 9 tool := &ThinkTool{} 10 11 result, err := tool.Run(context.Background(), `{"thought":"I should read the file first"}`) 12 if err != nil { 13 t.Fatalf("unexpected error: %v", err) 14 } 15 if result.IsError { 16 t.Fatalf("unexpected tool error: %s", result.Content) 17 } 18 if result.Content != "I should read the file first" { 19 t.Errorf("expected thought text back, got %q", result.Content) 20 } 21 } 22 23 func TestThinkTool_EmptyThought(t *testing.T) { 24 tool := &ThinkTool{} 25 26 result, err := tool.Run(context.Background(), `{"thought":""}`) 27 if err != nil { 28 t.Fatalf("unexpected error: %v", err) 29 } 30 if !result.IsError { 31 t.Error("expected error for empty thought") 32 } 33 } 34 35 func TestThinkTool_InvalidJSON(t *testing.T) { 36 tool := &ThinkTool{} 37 38 result, err := tool.Run(context.Background(), `not json`) 39 if err != nil { 40 t.Fatalf("unexpected error: %v", err) 41 } 42 if !result.IsError { 43 t.Error("expected error for invalid JSON") 44 } 45 } 46 47 func TestThinkTool_Info(t *testing.T) { 48 tool := &ThinkTool{} 49 info := tool.Info() 50 51 if info.Name != "think" { 52 t.Errorf("expected name 'think', got %q", info.Name) 53 } 54 if tool.RequiresApproval() { 55 t.Error("think tool should not require approval") 56 } 57 }