.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools / gopls@v0.6.9 / internal / regtest / misc / configuration_test.go
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 package misc
6
7 import (
8         "testing"
9
10         . "golang.org/x/tools/gopls/internal/regtest"
11
12         "golang.org/x/tools/internal/lsp/fake"
13         "golang.org/x/tools/internal/testenv"
14 )
15
16 // Test that enabling and disabling produces the expected results of showing
17 // and hiding staticcheck analysis results.
18 func TestChangeConfiguration(t *testing.T) {
19         // Staticcheck only supports Go versions > 1.14.
20         testenv.NeedsGo1Point(t, 15)
21
22         const files = `
23 -- go.mod --
24 module mod.com
25
26 go 1.12
27 -- a/a.go --
28 package a
29
30 // NotThisVariable should really start with ThisVariable.
31 const ThisVariable = 7
32 `
33         Run(t, files, func(t *testing.T, env *Env) {
34                 env.OpenFile("a/a.go")
35                 env.Await(
36                         env.DoneWithOpen(),
37                         NoDiagnostics("a/a.go"),
38                 )
39                 cfg := &fake.EditorConfig{}
40                 *cfg = env.Editor.Config
41                 cfg.EnableStaticcheck = true
42                 env.ChangeConfiguration(t, cfg)
43                 env.Await(
44                         DiagnosticAt("a/a.go", 2, 0),
45                 )
46         })
47 }