summaryrefslogtreecommitdiff
path: root/internal/lsp/init_shutdown_test.go
blob: 28471705c3eb9a11733c1f8e2166440693881ee6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package lsp

import (
	"bytes"
	"encoding/json"
	"io"
	"log"
	"testing"
)

func TestHandleShutdown_Replies(t *testing.T) {
	var out bytes.Buffer
	s := &Server{logger: log.New(io.Discard, "", 0), docs: make(map[string]*document), out: &out}
	initServerDefaults(s)
	req := Request{JSONRPC: "2.0", ID: json.RawMessage("12"), Method: "shutdown"}
	out.Reset()
	s.handleShutdown(req)
	resp := captureResponse(t, &out)
	if string(resp.ID) != "12" || resp.Error != nil {
		t.Fatalf("unexpected shutdown response: %+v", resp)
	}
}