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

Function TestDocumentLink_WSL

internal/compose/documentLink_test.go:29–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27}
28
29func TestDocumentLink_WSL(t *testing.T) {
30 composeStringURI := "file://wsl%24/docker-desktop/tmp/compose.yaml"
31 testCases := []struct {
32 name string
33 content string
34 links []protocol.DocumentLink
35 }{
36 {
37 name: "included files, string array",
38 content: `include:
39 - file.yaml
40 - ./file2.yaml
41 - ../other/file3.yaml`,
42 links: []protocol.DocumentLink{
43 {
44 Range: protocol.Range{
45 Start: protocol.Position{Line: 1, Character: 4},
46 End: protocol.Position{Line: 1, Character: 13},
47 },
48 Target: types.CreateStringPointer("file://wsl%24/docker-desktop/tmp/file.yaml"),
49 Tooltip: types.CreateStringPointer("\\\\wsl$\\docker-desktop\\tmp\\file.yaml"),
50 },
51 {
52 Range: protocol.Range{
53 Start: protocol.Position{Line: 2, Character: 4},
54 End: protocol.Position{Line: 2, Character: 16},
55 },
56 Target: types.CreateStringPointer("file://wsl%24/docker-desktop/tmp/file2.yaml"),
57 Tooltip: types.CreateStringPointer("\\\\wsl$\\docker-desktop\\tmp\\file2.yaml"),
58 },
59 {
60 Range: protocol.Range{
61 Start: protocol.Position{Line: 3, Character: 4},
62 End: protocol.Position{Line: 3, Character: 23},
63 },
64 Target: types.CreateStringPointer("file://wsl%24/docker-desktop/other/file3.yaml"),
65 Tooltip: types.CreateStringPointer("\\\\wsl$\\docker-desktop\\other\\file3.yaml"),
66 },
67 },
68 },
69 }
70
71 for _, tc := range testCases {
72 t.Run(tc.name, func(t *testing.T) {
73 doc := document.NewComposeDocument(document.NewDocumentManager(), uri.URI(composeStringURI), 1, []byte(tc.content))
74 links, err := DocumentLink(context.Background(), composeStringURI, doc)
75 require.NoError(t, err)
76 require.Equal(t, tc.links, links)
77 })
78 }
79}
80
81func TestDocumentLink_IncludedFiles(t *testing.T) {
82 testsFolder := filepath.Join(os.TempDir(), "composeDocumentLinkTests")

Callers

nothing calls this directly

Calls 5

CreateStringPointerFunction · 0.92
NewComposeDocumentFunction · 0.92
NewDocumentManagerFunction · 0.92
DocumentLinkFunction · 0.70
URIMethod · 0.65

Tested by

no test coverage detected