Skip to content

Commit 002d754

Browse files
committed
internal/lsp/regtest: add test for a GOPATH that's missing an element
Test the case described in fatih/vim-go#2673 (comment). Change-Id: I55ff3b8719fc255ec0901cf3778e68b48630323d Reviewed-on: https://go-review.googlesource.com/c/tools/+/232360 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent c20a87c commit 002d754

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

internal/lsp/regtest/unix_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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.
4+
5+
// +build !windows
6+
7+
package regtest
8+
9+
import (
10+
"fmt"
11+
"testing"
12+
)
13+
14+
func TestBadGOPATH(t *testing.T) {
15+
const missingImport = `
16+
-- main.go --
17+
package main
18+
19+
func _() {
20+
fmt.Println("Hello World")
21+
}
22+
`
23+
// Test the case given in
24+
// https://github.com/fatih/vim-go/issues/2673#issuecomment-622307211.
25+
runner.Run(t, missingImport, func(t *testing.T, env *Env) {
26+
env.OpenFile("main.go")
27+
env.Await(env.DiagnosticAtRegexp("main.go", "fmt"))
28+
if err := env.Editor.OrganizeImports(env.Ctx, "main.go"); err != nil {
29+
t.Fatal(err)
30+
}
31+
}, WithEnv(fmt.Sprintf("GOPATH=:/path/to/gopath")))
32+
}

0 commit comments

Comments
 (0)