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
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools/gopls@v0.5.2/internal/regtest/vendor_test.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools/gopls@v0.5.2/internal/regtest/vendor_test.go
new file mode 100644 (file)
index 0000000..7f11d4a
--- /dev/null
@@ -0,0 +1,66 @@
+package regtest
+
+import (
+       "testing"
+
+       "golang.org/x/tools/internal/lsp"
+       "golang.org/x/tools/internal/testenv"
+)
+
+const basicProxy = `
+-- golang.org/x/hello@v1.2.3/go.mod --
+module golang.org/x/hello
+
+go 1.14
+-- golang.org/x/hello@v1.2.3/hi/hi.go --
+package hi
+
+var Goodbye error
+`
+
+func TestInconsistentVendoring(t *testing.T) {
+       testenv.NeedsGo1Point(t, 14)
+       const pkgThatUsesVendoring = `
+-- go.mod --
+module mod.com
+
+go 1.14
+
+require golang.org/x/hello v1.2.3
+-- vendor/modules.txt --
+-- a/a1.go --
+package a
+
+import "golang.org/x/hello/hi"
+
+func _() {
+       _ = hi.Goodbye
+       var q int // hardcode a diagnostic
+}
+`
+       // TODO(rstambler): Remove this when golang/go#41819 is resolved.
+       withOptions(
+               WithModes(WithoutExperiments),
+               WithProxyFiles(basicProxy),
+       ).run(t, pkgThatUsesVendoring, func(t *testing.T, env *Env) {
+               env.OpenFile("a/a1.go")
+               env.Await(
+                       // The editor should pop up a message suggesting that the user
+                       // run `go mod vendor`, along with a button to do so.
+                       // By default, the fake editor always accepts such suggestions,
+                       // so once we see the request, we can assume that `go mod vendor`
+                       // will be executed.
+                       OnceMet(
+                               CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidOpen), 1),
+                               ShowMessageRequest("go mod vendor"),
+                       ),
+               )
+               env.CheckForFileChanges()
+               env.Await(
+                       OnceMet(
+                               CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidChangeWatchedFiles), 1),
+                               DiagnosticAt("a/a1.go", 6, 5),
+                       ),
+               )
+       })
+}