MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestHandler_DocumentSymbol

Function TestHandler_DocumentSymbol

pkg/lsp/handler_test.go:26–168  ·  view source on GitHub ↗

TestHandler_DocumentSymbol tests document symbol extraction

(t *testing.T)

Source from the content-addressed store, hash-verified

24
25// TestHandler_DocumentSymbol tests document symbol extraction
26func TestHandler_DocumentSymbol(t *testing.T) {
27 tests := []struct {
28 name string
29 sql string
30 expectedCount int
31 checkSymbols func(t *testing.T, symbols []DocumentSymbol)
32 }{
33 {
34 name: "SELECT statement returns SymbolMethod kind",
35 sql: "SELECT * FROM users",
36 expectedCount: 1,
37 checkSymbols: func(t *testing.T, symbols []DocumentSymbol) {
38 if symbols[0].Kind != SymbolMethod {
39 t.Errorf("expected SymbolMethod, got %v", symbols[0].Kind)
40 }
41 if !strings.HasPrefix(symbols[0].Name, "SELECT") {
42 t.Errorf("expected name to start with SELECT, got %s", symbols[0].Name)
43 }
44 if symbols[0].Detail != "SELECT statement" {
45 t.Errorf("expected detail 'SELECT statement', got %s", symbols[0].Detail)
46 }
47 },
48 },
49 {
50 name: "INSERT statement returns SymbolMethod kind",
51 sql: "INSERT INTO users (name) VALUES ('test')",
52 expectedCount: 1,
53 checkSymbols: func(t *testing.T, symbols []DocumentSymbol) {
54 if symbols[0].Kind != SymbolMethod {
55 t.Errorf("expected SymbolMethod, got %v", symbols[0].Kind)
56 }
57 if !strings.HasPrefix(symbols[0].Name, "INSERT") {
58 t.Errorf("expected name to start with INSERT, got %s", symbols[0].Name)
59 }
60 },
61 },
62 {
63 name: "UPDATE statement returns SymbolMethod kind",
64 sql: "UPDATE users SET name = 'test' WHERE id = 1",
65 expectedCount: 1,
66 checkSymbols: func(t *testing.T, symbols []DocumentSymbol) {
67 if symbols[0].Kind != SymbolMethod {
68 t.Errorf("expected SymbolMethod, got %v", symbols[0].Kind)
69 }
70 if !strings.HasPrefix(symbols[0].Name, "UPDATE") {
71 t.Errorf("expected name to start with UPDATE, got %s", symbols[0].Name)
72 }
73 },
74 },
75 {
76 name: "DELETE statement returns SymbolMethod kind",
77 sql: "DELETE FROM users WHERE id = 1",
78 expectedCount: 1,
79 checkSymbols: func(t *testing.T, symbols []DocumentSymbol) {
80 if symbols[0].Kind != SymbolMethod {
81 t.Errorf("expected SymbolMethod, got %v", symbols[0].Kind)
82 }
83 if !strings.HasPrefix(symbols[0].Name, "DELETE") {

Callers

nothing calls this directly

Calls 8

DocumentsMethod · 0.95
newMockReadWriterFunction · 0.85
NewServerFunction · 0.85
RunMethod · 0.80
OpenMethod · 0.80
HandleRequestMethod · 0.80
ErrorfMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected