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

Function TestFunctional_Completion_Keywords

pkg/lsp/handler_functional_test.go:117–151  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Completion ---------------------------------------------------------------------------

(t *testing.T)

Source from the content-addressed store, hash-verified

115// ---------------------------------------------------------------------------
116
117func TestFunctional_Completion_Keywords(t *testing.T) {
118 mock := newMockReadWriter()
119 logger := log.New(io.Discard, "", 0)
120 server := NewServer(mock.input, mock.output, logger)
121
122 server.Documents().Open("file:///test.sql", "sql", 1, "SEL")
123
124 params := CompletionParams{
125 TextDocumentPositionParams: TextDocumentPositionParams{
126 TextDocument: TextDocumentIdentifier{URI: "file:///test.sql"},
127 Position: Position{Line: 0, Character: 3},
128 },
129 }
130 raw, _ := json.Marshal(params)
131 result, err := server.handler.HandleRequest("textDocument/completion", raw)
132 if err != nil {
133 t.Fatal(err)
134 }
135
136 list := result.(*CompletionList)
137 if len(list.Items) == 0 {
138 t.Fatal("expected completion items for 'SEL'")
139 }
140
141 foundSelect := false
142 for _, item := range list.Items {
143 if item.Label == "SELECT" {
144 foundSelect = true
145 break
146 }
147 }
148 if !foundSelect {
149 t.Error("expected SELECT in completion results")
150 }
151}
152
153func TestFunctional_Completion_EmptyPrefix(t *testing.T) {
154 mock := newMockReadWriter()

Callers

nothing calls this directly

Calls 6

DocumentsMethod · 0.95
newMockReadWriterFunction · 0.85
NewServerFunction · 0.85
OpenMethod · 0.80
HandleRequestMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected