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>
(cherry picked from commit 7103138b8bf45fc6f125daec4d8542a0f37385e4)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/389495
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/gopls/internal/regtest/diagnostics/diagnostics_test.go b/gopls/internal/regtest/diagnostics/diagnostics_test.go
index e5b346c..b9802e2 100644
--- a/gopls/internal/regtest/diagnostics/diagnostics_test.go
+++ b/gopls/internal/regtest/diagnostics/diagnostics_test.go
@@ -2185,3 +2185,33 @@
 		}
 	})
 }
+
+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"),
+		)
+	})
+}