2019-10-29 02:41:12 -06:00
|
|
|
// Copyright 2019 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package cmdtest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"golang.org/x/tools/internal/span"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (r *runner) Import(t *testing.T, spn span.Span) {
|
|
|
|
uri := spn.URI()
|
|
|
|
filename := uri.Filename()
|
2019-11-21 17:58:38 -07:00
|
|
|
got, _ := r.NormalizeGoplsCmd(t, "imports", filename)
|
2019-10-29 02:41:12 -06:00
|
|
|
want := string(r.data.Golden("goimports", filename, func() ([]byte, error) {
|
2019-12-04 18:39:06 -07:00
|
|
|
return []byte(got), nil
|
2019-10-29 02:41:12 -06:00
|
|
|
}))
|
|
|
|
if want != got {
|
2019-10-11 09:03:23 -06:00
|
|
|
t.Errorf("imports failed for %s, expected:\n%q\ngot:\n%q", filename, want, got)
|
2019-10-29 02:41:12 -06:00
|
|
|
}
|
|
|
|
}
|