(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestInlineCompletion(t *testing.T) { |
| 18 | s := startServer() |
| 19 | |
| 20 | client := bytes.NewBuffer(make([]byte, 0, 1024)) |
| 21 | server := bytes.NewBuffer(make([]byte, 0, 1024)) |
| 22 | serverStream := &TestStream{incoming: server, outgoing: client, closed: false} |
| 23 | defer serverStream.Close() |
| 24 | go s.ServeStream(serverStream) |
| 25 | |
| 26 | clientStream := jsonrpc2.NewBufferedStream(&TestStream{incoming: client, outgoing: server, closed: false}, jsonrpc2.VSCodeObjectCodec{}) |
| 27 | defer clientStream.Close() |
| 28 | conn := jsonrpc2.NewConn(context.Background(), clientStream, &ConfigurationHandler{t: t}) |
| 29 | initialize(t, conn, protocol.InitializeParams{}) |
| 30 | |
| 31 | testCases := []struct { |
| 32 | name string |
| 33 | content string |
| 34 | line protocol.UInteger |
| 35 | character protocol.UInteger |
| 36 | dockerfileContent string |
| 37 | items []protocol.InlineCompletionItem |
| 38 | }{ |
| 39 | { |
| 40 | name: "one build stage", |
| 41 | content: "", |
| 42 | line: 0, |
| 43 | character: 0, |
| 44 | dockerfileContent: "FROM scratch AS simple", |
| 45 | items: []protocol.InlineCompletionItem{ |
| 46 | { |
| 47 | InsertText: "target \"simple\" {\n target = \"simple\"\n}\n", |
| 48 | Range: &protocol.Range{ |
| 49 | Start: protocol.Position{Line: 0, Character: 0}, |
| 50 | End: protocol.Position{Line: 0, Character: 0}, |
| 51 | }, |
| 52 | }, |
| 53 | }, |
| 54 | }, |
| 55 | { |
| 56 | name: "outside document bounds", |
| 57 | content: "", |
| 58 | line: 1, |
| 59 | character: 0, |
| 60 | dockerfileContent: "FROM scratch AS simple", |
| 61 | items: nil, |
| 62 | }, |
| 63 | } |
| 64 | |
| 65 | temporaryDockerfile := fmt.Sprintf("file:///%v", strings.TrimPrefix(filepath.ToSlash(filepath.Join(os.TempDir(), "Dockerfile")), "/")) |
| 66 | temporaryBakeFile := fmt.Sprintf("file:///%v", strings.TrimPrefix(filepath.ToSlash(filepath.Join(os.TempDir(), "docker-bake.hcl")), "/")) |
| 67 | |
| 68 | for _, tc := range testCases { |
| 69 | t.Run(tc.name, func(t *testing.T) { |
| 70 | didOpenDockerfile := protocol.DidOpenTextDocumentParams{ |
| 71 | TextDocument: protocol.TextDocumentItem{ |
| 72 | URI: temporaryDockerfile, |
| 73 | Text: tc.dockerfileContent, |
| 74 | LanguageID: "dockerfile", |
nothing calls this directly
no test coverage detected