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 / rename.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/span"
12 )
13
14 func (r *runner) Rename(t *testing.T, spn span.Span, newText string) {
15         filename := spn.URI().Filename()
16         goldenTag := newText + "-rename"
17         loc := fmt.Sprintf("%v", spn)
18         got, err := r.NormalizeGoplsCmd(t, "rename", loc, newText)
19         got += err
20         expect := string(r.data.Golden(goldenTag, filename, func() ([]byte, error) {
21                 return []byte(got), nil
22         }))
23         if expect != got {
24                 t.Errorf("rename failed with %v %v\nexpected:\n%s\ngot:\n%s", loc, newText, expect, got)
25         }
26         // now check we can build a valid unified diff
27         unified, _ := r.NormalizeGoplsCmd(t, "rename", "-d", loc, newText)
28         checkUnified(t, filename, expect, unified)
29 }