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.
11 "golang.org/x/tools/internal/span"
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)
20 expect := string(r.data.Golden(goldenTag, filename, func() ([]byte, error) {
21 return []byte(got), nil
24 t.Errorf("rename failed with %v %v\nexpected:\n%s\ngot:\n%s", loc, newText, expect, got)
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)