Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools / gopls@v0.5.2 / internal / regtest / vendor_test.go
1 package regtest
2
3 import (
4         "testing"
5
6         "golang.org/x/tools/internal/lsp"
7         "golang.org/x/tools/internal/testenv"
8 )
9
10 const basicProxy = `
11 -- golang.org/x/hello@v1.2.3/go.mod --
12 module golang.org/x/hello
13
14 go 1.14
15 -- golang.org/x/hello@v1.2.3/hi/hi.go --
16 package hi
17
18 var Goodbye error
19 `
20
21 func TestInconsistentVendoring(t *testing.T) {
22         testenv.NeedsGo1Point(t, 14)
23         const pkgThatUsesVendoring = `
24 -- go.mod --
25 module mod.com
26
27 go 1.14
28
29 require golang.org/x/hello v1.2.3
30 -- vendor/modules.txt --
31 -- a/a1.go --
32 package a
33
34 import "golang.org/x/hello/hi"
35
36 func _() {
37         _ = hi.Goodbye
38         var q int // hardcode a diagnostic
39 }
40 `
41         // TODO(rstambler): Remove this when golang/go#41819 is resolved.
42         withOptions(
43                 WithModes(WithoutExperiments),
44                 WithProxyFiles(basicProxy),
45         ).run(t, pkgThatUsesVendoring, func(t *testing.T, env *Env) {
46                 env.OpenFile("a/a1.go")
47                 env.Await(
48                         // The editor should pop up a message suggesting that the user
49                         // run `go mod vendor`, along with a button to do so.
50                         // By default, the fake editor always accepts such suggestions,
51                         // so once we see the request, we can assume that `go mod vendor`
52                         // will be executed.
53                         OnceMet(
54                                 CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidOpen), 1),
55                                 ShowMessageRequest("go mod vendor"),
56                         ),
57                 )
58                 env.CheckForFileChanges()
59                 env.Await(
60                         OnceMet(
61                                 CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidChangeWatchedFiles), 1),
62                                 DiagnosticAt("a/a1.go", 6, 5),
63                         ),
64                 )
65         })
66 }