gopls: add regtest for edit go directive quick fix

Change-Id: Id02a51b8513e11c688a1da9e7e1af66481d4881e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/389255
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Suzy Mueller 2022-03-02 11:35:52 -07:00
parent 4a5e7f0db6
commit 7103138b8b
1 changed files with 30 additions and 0 deletions

View File

@ -2185,3 +2185,33 @@ func F[T C](_ T) {
}
})
}
func TestEditGoDirective(t *testing.T) {
testenv.NeedsGo1Point(t, 18)
const files = `
-- go.mod --
module mod.com
go 1.16
-- main.go --
package main
func F[T any](_ T) {
}
`
Run(t, files, func(t *testing.T, env *Env) { // Create a new workspace-level directory and empty file.
var d protocol.PublishDiagnosticsParams
env.Await(
OnceMet(
env.DiagnosticAtRegexpWithMessage("main.go", `T any`, "type parameters require"),
ReadDiagnostics("main.go", &d),
),
)
env.ApplyQuickFixes("main.go", d.Diagnostics)
env.Await(
EmptyDiagnostics("main.go"),
)
})
}