/
configuration_test.go
49 lines (40 loc) · 1.04 KB
/
configuration_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// 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.
package misc
import (
"testing"
. "golang.org/x/tools/gopls/internal/regtest"
"golang.org/x/tools/internal/lsp/fake"
"golang.org/x/tools/internal/testenv"
)
// Test that enabling and disabling produces the expected results of showing
// and hiding staticcheck analysis results.
func TestChangeConfiguration(t *testing.T) {
// Staticcheck only supports Go versions > 1.14.
testenv.NeedsGo1Point(t, 15)
const files = `
-- go.mod --
module mod.com
go 1.12
-- a/a.go --
package a
import "errors"
// FooErr should be called ErrFoo (ST1012)
var FooErr = errors.New("foo")
`
Run(t, files, func(t *testing.T, env *Env) {
env.OpenFile("a/a.go")
env.Await(
env.DoneWithOpen(),
NoDiagnostics("a/a.go"),
)
cfg := &fake.EditorConfig{}
*cfg = env.Editor.Config
cfg.EnableStaticcheck = true
env.ChangeConfiguration(t, cfg)
env.Await(
DiagnosticAt("a/a.go", 5, 4),
)
})
}