Skip to content

Commit

Permalink
fix: include initialized call on each successive initialize(). use ra…
Browse files Browse the repository at this point in the history
…w code for TestInitialized
  • Loading branch information
nedpals committed Feb 2, 2024
1 parent 911791a commit 11a4a78
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion server/lsp_server/lsp_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func Setup() (func(), *LspServer, *rpc.Client) {
func initialize(lspServer *LspServer, client *rpc.Client) (lsp.InitializeResult, error) {
var result lsp.InitializeResult
err := client.Call(lsp.MethodInitialize, nil, &result)
if err == nil {
client.Notify(lsp.MethodInitialized, nil)
}
return result, err
}

Expand Down Expand Up @@ -122,11 +125,40 @@ func TestInitialized(t *testing.T) {
close, srv, client := Setup()
defer close()

_, err := initialize(srv, client)
var result lsp.InitializeResult
err := client.Call(lsp.MethodInitialize, nil, &result)
if err != nil {
t.Fatal(err)
}

exp := lsp.InitializeResult{
Capabilities: lsp.ServerCapabilities{
TextDocumentSync: lsp.TextDocumentSyncKindFull,
CompletionProvider: nil,
HoverProvider: nil,
},
ServerInfo: &lsp.ServerInfo{
Name: "BugBuddy",
Version: srv.version,
},
}

if result.Capabilities.TextDocumentSync == nil {
t.Error("Expected TextDocumentSync to be non-nil")
}

if tdSync := lsp.TextDocumentSyncKind(result.Capabilities.TextDocumentSync.(float64)); tdSync != exp.Capabilities.TextDocumentSync {
t.Errorf("Expected %v, got %v", exp.Capabilities.TextDocumentSync, tdSync)
}

if exp.ServerInfo.Name != result.ServerInfo.Name {
t.Errorf("Expected %v, got %v", exp.ServerInfo.Name, result.ServerInfo.Name)
}

if exp.ServerInfo.Version != result.ServerInfo.Version {
t.Errorf("Expected %v, got %v", exp.ServerInfo.Version, result.ServerInfo.Version)
}

err = client.Notify(lsp.MethodInitialized, nil)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 11a4a78

Please sign in to comment.