Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201028153306-37f0764111ff / internal / lsp / cmd / test / suggested_fix.go
1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package cmdtest
6
7 import (
8         "fmt"
9         "testing"
10
11         "golang.org/x/tools/internal/lsp/tests"
12         "golang.org/x/tools/internal/span"
13 )
14
15 func (r *runner) SuggestedFix(t *testing.T, spn span.Span, actionKinds []string) {
16         uri := spn.URI()
17         filename := uri.Filename()
18         args := []string{"fix", "-a", fmt.Sprintf("%s", spn)}
19         for _, kind := range actionKinds {
20                 if kind == "refactor.rewrite" {
21                         t.Skip("refactor.rewrite is not yet supported on the command line")
22                 }
23         }
24         args = append(args, actionKinds...)
25         got, stderr := r.NormalizeGoplsCmd(t, args...)
26         if stderr == "ExecuteCommand is not yet supported on the command line" {
27                 t.Skipf(stderr)
28         }
29         want := string(r.data.Golden("suggestedfix_"+tests.SpanName(spn), filename, func() ([]byte, error) {
30                 return []byte(got), nil
31         }))
32         if want != got {
33                 t.Errorf("suggested fixes failed for %s:\n%s", filename, tests.Diff(want, got))
34         }
35 }