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

Function TestGetFunctionAtPosition

pkg/lsp/handler_test.go:576–644  ·  view source on GitHub ↗

TestGetFunctionAtPosition tests the internal function position detection

(t *testing.T)

Source from the content-addressed store, hash-verified

574
575// TestGetFunctionAtPosition tests the internal function position detection
576func TestGetFunctionAtPosition(t *testing.T) {
577 mock := newMockReadWriter()
578 logger := log.New(io.Discard, "", 0)
579 server := NewServer(mock.input, mock.output, logger)
580 handler := server.handler
581
582 tests := []struct {
583 name string
584 content string
585 position Position
586 expectedFunc string
587 expectedParam int
588 }{
589 {
590 name: "Simple function call",
591 content: "SELECT COUNT(*) FROM users",
592 position: Position{Line: 0, Character: 13},
593 expectedFunc: "COUNT",
594 expectedParam: 0,
595 },
596 {
597 name: "Function with multiple params - first param",
598 content: "SELECT COALESCE(name, email, phone) FROM users",
599 position: Position{Line: 0, Character: 20},
600 expectedFunc: "COALESCE",
601 expectedParam: 0,
602 },
603 {
604 name: "Function with multiple params - second param",
605 content: "SELECT COALESCE(name, email, phone) FROM users",
606 position: Position{Line: 0, Character: 27},
607 expectedFunc: "COALESCE",
608 expectedParam: 1,
609 },
610 {
611 name: "Function with multiple params - third param",
612 content: "SELECT COALESCE(name, email, phone) FROM users",
613 position: Position{Line: 0, Character: 34},
614 expectedFunc: "COALESCE",
615 expectedParam: 2,
616 },
617 {
618 name: "Nested function - outer",
619 content: "SELECT UPPER(TRIM(name)) FROM users",
620 position: Position{Line: 0, Character: 23},
621 expectedFunc: "UPPER",
622 expectedParam: 0,
623 },
624 {
625 name: "Position outside function",
626 content: "SELECT * FROM users",
627 position: Position{Line: 0, Character: 8},
628 expectedFunc: "",
629 expectedParam: 0,
630 },
631 }
632
633 for _, tt := range tests {

Callers

nothing calls this directly

Calls 5

newMockReadWriterFunction · 0.85
NewServerFunction · 0.85
RunMethod · 0.80
getFunctionAtPositionMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected