package llm import ( "testing" ) func TestGetKnowledgeGraphTools_ReturnsTools(t *testing.T) { tools := GetKnowledgeGraphTools() if len(tools) == 0 { t.Fatal("GetKnowledgeGraphTools() returned no tools") } if len(tools) != 6 { t.Fatalf("expected 6 tools, got %d", len(tools)) } } func TestGetKnowledgeGraphTools_ToolNames(t *testing.T) { tools := GetKnowledgeGraphTools() expected := map[string]bool{ "search_nodes": true, "get_neighbors": true, "create_node": true, "create_edge": true, "delete_node": true, "delete_edge": true, } for _, tool := range tools { if tool.Function == nil { t.Error("tool has nil Function definition") continue } name := tool.Function.Name if !expected[name] { t.Errorf("unexpected tool name: %s", name) } delete(expected, name) } if len(expected) > 0 { t.Errorf("missing tools: %v", expected) } } func TestGetKnowledgeGraphTools_HasDescriptions(t *testing.T) { tools := GetKnowledgeGraphTools() for _, tool := range tools { if tool.Function == nil { continue } if tool.Function.Description == "" { t.Errorf("tool %s has empty description", tool.Function.Name) } } } func TestGetKnowledgeGraphTools_HasParameters(t *testing.T) { tools := GetKnowledgeGraphTools() for _, tool := range tools { if tool.Function == nil { continue } params, ok := tool.Function.Parameters.(map[string]any) if !ok { t.Errorf("tool %s parameters is not map[string]any", tool.Function.Name) continue } if params["type"] != "object" { t.Errorf("tool %s parameters type is not 'object'", tool.Function.Name) } props, ok := params["properties"].(map[string]any) if !ok { t.Errorf("tool %s has no properties map", tool.Function.Name) continue } if len(props) == 0 { t.Errorf("tool %s has empty properties", tool.Function.Name) } } } func TestGetKnowledgeGraphTools_RequiredFields(t *testing.T) { tools := GetKnowledgeGraphTools() for _, tool := range tools { if tool.Function == nil { continue } params := tool.Function.Parameters.(map[string]any) required, ok := params["required"].([]string) if !ok { t.Errorf("tool %s has no required fields", tool.Function.Name) continue } if len(required) == 0 { t.Errorf("tool %s has empty required fields", tool.Function.Name) } } } func TestGetKnowledgeGraphTools_NoDuplicates(t *testing.T) { tools := GetKnowledgeGraphTools() seen := map[string]bool{} for _, tool := range tools { if tool.Function == nil { continue } name := tool.Function.Name if seen[name] { t.Errorf("duplicate tool name: %s", name) } seen[name] = true } }