1 // Copyright 2020 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.
10 . "golang.org/x/tools/gopls/internal/regtest"
12 "golang.org/x/tools/internal/lsp/protocol"
13 "golang.org/x/tools/internal/testenv"
17 -- golang.org/x/hello@v1.2.3/go.mod --
18 module golang.org/x/hello
21 -- golang.org/x/hello@v1.2.3/hi/hi.go --
27 func TestInconsistentVendoring(t *testing.T) {
28 testenv.NeedsGo1Point(t, 14)
30 const pkgThatUsesVendoring = `
36 require golang.org/x/hello v1.2.3
38 golang.org/x/hello v1.2.3 h1:EcMp5gSkIhaTkPXp8/3+VH+IFqTpk3ZbpOhqk0Ncmho=
39 golang.org/x/hello v1.2.3/go.mod h1:WW7ER2MRNXWA6c8/4bDIek4Hc/+DofTrMaQQitGXcco=
40 -- vendor/modules.txt --
44 import "golang.org/x/hello/hi"
48 var q int // hardcode a diagnostic
53 ProxyFiles(basicProxy),
54 ).Run(t, pkgThatUsesVendoring, func(t *testing.T, env *Env) {
55 env.OpenFile("a/a1.go")
56 d := &protocol.PublishDiagnosticsParams{}
59 env.DiagnosticAtRegexpWithMessage("go.mod", "module mod.com", "Inconsistent vendoring"),
60 ReadDiagnostics("go.mod", d),
63 env.ApplyQuickFixes("go.mod", d.Diagnostics)
66 env.DiagnosticAtRegexpWithMessage("a/a1.go", `q int`, "not used"),