(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestDocumentLink(t *testing.T) { |
| 19 | testsFolder := filepath.Join(os.TempDir(), "documentLinkTests") |
| 20 | userFolder := filepath.Join(testsFolder, "user") |
| 21 | bakeFilePath := filepath.Join(userFolder, "docker-bake.hcl") |
| 22 | bakeFileStringURI := fmt.Sprintf("file:///%v", strings.TrimPrefix(filepath.ToSlash(bakeFilePath), "/")) |
| 23 | |
| 24 | testCases := []struct { |
| 25 | name string |
| 26 | content string |
| 27 | path string |
| 28 | linkRange protocol.Range |
| 29 | links func(path string) []protocol.DocumentLink |
| 30 | }{ |
| 31 | { |
| 32 | name: "dockerfile attribute in targets block", |
| 33 | content: "target \"api\" {\n dockerfile = \"Dockerfile.api\"\n}", |
| 34 | path: filepath.Join(userFolder, "Dockerfile.api"), |
| 35 | linkRange: protocol.Range{ |
| 36 | Start: protocol.Position{Line: 1, Character: 16}, |
| 37 | End: protocol.Position{Line: 1, Character: 30}, |
| 38 | }, |
| 39 | }, |
| 40 | { |
| 41 | name: "./dockerfile attribute in targets block", |
| 42 | content: "target \"api\" {\n dockerfile = \"./Dockerfile.api\"\n}", |
| 43 | path: filepath.Join(userFolder, "Dockerfile.api"), |
| 44 | linkRange: protocol.Range{ |
| 45 | Start: protocol.Position{Line: 1, Character: 16}, |
| 46 | End: protocol.Position{Line: 1, Character: 32}, |
| 47 | }, |
| 48 | }, |
| 49 | { |
| 50 | name: "../dockerfile attribute in targets block", |
| 51 | content: "target \"api\" {\n dockerfile = \"../Dockerfile.api\"\n}", |
| 52 | path: filepath.Join(testsFolder, "Dockerfile.api"), |
| 53 | linkRange: protocol.Range{ |
| 54 | Start: protocol.Position{Line: 1, Character: 16}, |
| 55 | End: protocol.Position{Line: 1, Character: 33}, |
| 56 | }, |
| 57 | }, |
| 58 | { |
| 59 | name: "folder/dockerfile attribute in targets block", |
| 60 | content: "target \"api\" {\n dockerfile = \"folder/Dockerfile.api\"\n}", |
| 61 | path: filepath.Join(filepath.Join(userFolder, "folder"), "Dockerfile.api"), |
| 62 | linkRange: protocol.Range{ |
| 63 | Start: protocol.Position{Line: 1, Character: 16}, |
| 64 | End: protocol.Position{Line: 1, Character: 37}, |
| 65 | }, |
| 66 | }, |
| 67 | { |
| 68 | name: "../folder/dockerfile attribute in targets block", |
| 69 | content: "target \"api\" {\n dockerfile = \"../folder/Dockerfile.api\"\n}", |
| 70 | path: filepath.Join(filepath.Join(testsFolder, "folder"), "Dockerfile.api"), |
| 71 | linkRange: protocol.Range{ |
| 72 | Start: protocol.Position{Line: 1, Character: 16}, |
| 73 | End: protocol.Position{Line: 1, Character: 40}, |
| 74 | }, |
| 75 | }, |
nothing calls this directly
no test coverage detected