Skip to content

Commit fa15af6

Browse files
suzmuefindleyr
authored andcommitted
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 <[email protected]> Run-TryBot: Suzy Mueller <[email protected]> Reviewed-by: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Gopher Robot <[email protected]> (cherry picked from commit 7103138) Reviewed-on: https://go-review.googlesource.com/c/tools/+/389495 Trust: Robert Findley <[email protected]> Run-TryBot: Robert Findley <[email protected]> Trust: Hyang-Ah Hana Kim <[email protected]>
1 parent fd9fd22 commit fa15af6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

gopls/internal/regtest/diagnostics/diagnostics_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,3 +2185,33 @@ func F[T C](_ T) {
21852185
}
21862186
})
21872187
}
2188+
2189+
func TestEditGoDirective(t *testing.T) {
2190+
testenv.NeedsGo1Point(t, 18)
2191+
const files = `
2192+
-- go.mod --
2193+
module mod.com
2194+
2195+
go 1.16
2196+
-- main.go --
2197+
package main
2198+
2199+
func F[T any](_ T) {
2200+
}
2201+
`
2202+
Run(t, files, func(t *testing.T, env *Env) { // Create a new workspace-level directory and empty file.
2203+
var d protocol.PublishDiagnosticsParams
2204+
env.Await(
2205+
OnceMet(
2206+
env.DiagnosticAtRegexpWithMessage("main.go", `T any`, "type parameters require"),
2207+
ReadDiagnostics("main.go", &d),
2208+
),
2209+
)
2210+
2211+
env.ApplyQuickFixes("main.go", d.Diagnostics)
2212+
2213+
env.Await(
2214+
EmptyDiagnostics("main.go"),
2215+
)
2216+
})
2217+
}

0 commit comments

Comments
 (0)