MCPcopy Create free account
hub / github.com/docker/docker-language-server / TestDocumentLink

Function TestDocumentLink

e2e-tests/documentLink_test.go:18–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestDocumentLink(t *testing.T) {
19 s := startServer()
20
21 client := bytes.NewBuffer(make([]byte, 0, 1024))
22 server := bytes.NewBuffer(make([]byte, 0, 1024))
23 serverStream := &TestStream{incoming: server, outgoing: client, closed: false}
24 defer serverStream.Close()
25 go s.ServeStream(serverStream)
26
27 clientStream := jsonrpc2.NewBufferedStream(&TestStream{incoming: client, outgoing: server, closed: false}, jsonrpc2.VSCodeObjectCodec{})
28 defer clientStream.Close()
29 conn := jsonrpc2.NewConn(context.Background(), clientStream, &ConfigurationHandler{t: t})
30 initialize(t, conn, protocol.InitializeParams{})
31
32 homedir, err := os.UserHomeDir()
33 require.NoError(t, err)
34 testFolder := filepath.Join(homedir, t.Name())
35
36 testCases := []struct {
37 name string
38 content string
39 linkRange protocol.Range
40 path string
41 links []protocol.DocumentLink
42 }{
43 {
44 name: "dockerfile attribute in targets block",
45 content: "target \"api\" {\n dockerfile = \"Dockerfile.api\"\n}",
46 path: filepath.Join(homedir, "TestDocumentLink", "Dockerfile.api"),
47 linkRange: protocol.Range{
48 Start: protocol.Position{Line: 1, Character: 16},
49 End: protocol.Position{Line: 1, Character: 30},
50 },
51 },
52 {
53 name: "./dockerfile attribute in targets block",
54 content: "target \"api\" {\n dockerfile = \"./Dockerfile.api\"\n}",
55 path: filepath.Join(homedir, "TestDocumentLink", "Dockerfile.api"),
56 linkRange: protocol.Range{
57 Start: protocol.Position{Line: 1, Character: 16},
58 End: protocol.Position{Line: 1, Character: 32},
59 },
60 },
61 {
62 name: "../dockerfile attribute in targets block",
63 content: "target \"api\" {\n dockerfile = \"../Dockerfile.api\"\n}",
64 path: filepath.Join(homedir, "Dockerfile.api"),
65 linkRange: protocol.Range{
66 Start: protocol.Position{Line: 1, Character: 16},
67 End: protocol.Position{Line: 1, Character: 33},
68 },
69 },
70 {
71 name: "folder/dockerfile attribute in targets block",
72 content: "target \"api\" {\n dockerfile = \"folder/Dockerfile.api\"\n}",
73 path: filepath.Join(homedir, "TestDocumentLink", "folder", "Dockerfile.api"),
74 linkRange: protocol.Range{
75 Start: protocol.Position{Line: 1, Character: 16},

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
CreateStringPointerFunction · 0.92
startServerFunction · 0.85
initializeFunction · 0.85
CloseMethod · 0.65
ServeStreamMethod · 0.45

Tested by

no test coverage detected