TestHandler_DocumentSymbol tests document symbol extraction
(t *testing.T)
| 24 | |
| 25 | // TestHandler_DocumentSymbol tests document symbol extraction |
| 26 | func 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") { |
nothing calls this directly
no test coverage detected