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

Function TestDocumentManager

pkg/lsp/server_test.go:64–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestDocumentManager(t *testing.T) {
65 dm := NewDocumentManager()
66
67 // Test Open
68 dm.Open("file:///test.sql", "sql", 1, "SELECT * FROM users")
69
70 doc, ok := dm.Get("file:///test.sql")
71 if !ok {
72 t.Fatal("expected document to be found")
73 }
74 if doc.Content != "SELECT * FROM users" {
75 t.Errorf("expected content 'SELECT * FROM users', got %q", doc.Content)
76 }
77 if doc.Version != 1 {
78 t.Errorf("expected version 1, got %d", doc.Version)
79 }
80
81 // Test Update with full sync
82 dm.Update("file:///test.sql", 2, []TextDocumentContentChangeEvent{
83 {Text: "SELECT id FROM users"},
84 })
85
86 content, ok := dm.GetContent("file:///test.sql")
87 if !ok {
88 t.Fatal("expected content to be found")
89 }
90 if content != "SELECT id FROM users" {
91 t.Errorf("expected updated content, got %q", content)
92 }
93
94 // Test Close
95 dm.Close("file:///test.sql")
96 _, ok = dm.Get("file:///test.sql")
97 if ok {
98 t.Fatal("expected document to be closed")
99 }
100}
101
102func TestDocumentGetWordAtPosition(t *testing.T) {
103 doc := &Document{

Callers

nothing calls this directly

Calls 7

OpenMethod · 0.95
GetMethod · 0.95
UpdateMethod · 0.95
GetContentMethod · 0.95
CloseMethod · 0.95
NewDocumentManagerFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected