blob: 47dfc421ea69d8ed6d3d8ee0898af01ea426047a [file] [log] [blame]
// 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 regtest
import (
"testing"
"golang.org/x/tools/internal/lsp"
"golang.org/x/tools/internal/lsp/fake"
)
// Test that enabling and disabling produces the expected results of showing
// and hiding staticcheck analysis results.
func TestChangeConfiguration(t *testing.T) {
const files = `
-- go.mod --
module mod.com
go 1.12
-- a/a.go --
package a
// NotThisVariable should really start with ThisVariable.
const ThisVariable = 7
`
run(t, files, func(t *testing.T, env *Env) {
env.Await(
CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromInitialWorkspaceLoad), 1),
)
env.OpenFile("a/a.go")
env.Await(
CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidOpen), 1),
NoDiagnostics("a/a.go"),
)
cfg := &fake.EditorConfig{}
*cfg = env.Editor.Config
cfg.EnableStaticcheck = true
env.changeConfiguration(t, cfg)
env.Await(
DiagnosticAt("a/a.go", 2, 0),
)
})
}