2020-05-06 00:20:44 -06:00
|
|
|
// Copyright 2020 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.
|
|
|
|
|
2020-05-13 04:06:16 -06:00
|
|
|
// +build !windows,!plan9
|
2020-05-06 00:20:44 -06:00
|
|
|
|
|
|
|
package regtest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2020-05-06 20:54:50 -06:00
|
|
|
|
|
|
|
"golang.org/x/tools/internal/lsp/fake"
|
2020-05-06 00:20:44 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestBadGOPATH(t *testing.T) {
|
2020-07-22 12:03:48 -06:00
|
|
|
const files = `
|
2020-05-06 00:20:44 -06:00
|
|
|
-- main.go --
|
|
|
|
package main
|
|
|
|
|
|
|
|
func _() {
|
|
|
|
fmt.Println("Hello World")
|
|
|
|
}
|
|
|
|
`
|
2020-07-22 12:03:48 -06:00
|
|
|
editorConfig := fake.EditorConfig{
|
|
|
|
Env: map[string]string{"GOPATH": ":/path/to/gopath"},
|
|
|
|
}
|
2020-05-06 00:20:44 -06:00
|
|
|
// Test the case given in
|
|
|
|
// https://github.com/fatih/vim-go/issues/2673#issuecomment-622307211.
|
2020-07-22 12:03:48 -06:00
|
|
|
withOptions(WithEditorConfig(editorConfig)).run(t, files, func(t *testing.T, env *Env) {
|
2020-05-06 00:20:44 -06:00
|
|
|
env.OpenFile("main.go")
|
|
|
|
env.Await(env.DiagnosticAtRegexp("main.go", "fmt"))
|
|
|
|
if err := env.Editor.OrganizeImports(env.Ctx, "main.go"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-07-22 12:03:48 -06:00
|
|
|
})
|
2020-05-06 00:20:44 -06:00
|
|
|
}
|