aboutsummaryrefslogtreecommitdiff
path: root/gopls/internal/regtest/completion/completion_test.go
diff options
context:
space:
mode:
authorRobert Findley <rfindley@google.com>2022-12-29 09:56:30 -0500
committerRobert Findley <rfindley@google.com>2022-12-29 16:33:14 +0000
commit3b16059a0a4f211224d2ec02033449f722e5049f (patch)
treeb688de22350dfd0fe6d7a2aa67c144db26b74f1f /gopls/internal/regtest/completion/completion_test.go
parent0e1d01321381a6614cf23ae5b146eaa8e4c2040a (diff)
downloadgolang-x-tools-3b16059a0a4f211224d2ec02033449f722e5049f.tar.gz
gopls/internal/regtest: make BufferText strict
Make Editor.BufferText differentiate between empty and unopen files. Typically, the caller assumes that the file is open, so add a wrapper that implements this assertion. Change-Id: I5cd13a60e6884a45f30ca65726acd9220bcab346 Reviewed-on: https://go-review.googlesource.com/c/tools/+/459781 Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Dylan Le <dungtuanle@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'gopls/internal/regtest/completion/completion_test.go')
-rw-r--r--gopls/internal/regtest/completion/completion_test.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/gopls/internal/regtest/completion/completion_test.go b/gopls/internal/regtest/completion/completion_test.go
index 3d5afe4de..08a14215e 100644
--- a/gopls/internal/regtest/completion/completion_test.go
+++ b/gopls/internal/regtest/completion/completion_test.go
@@ -182,7 +182,7 @@ package
// Check that the completion item suggestions are in the range
// of the file.
- lineCount := len(strings.Split(env.Editor.BufferText(tc.filename), "\n"))
+ lineCount := len(strings.Split(env.BufferText(tc.filename), "\n"))
for _, item := range completions.Items {
if start := int(item.TextEdit.Range.Start.Line); start >= lineCount {
t.Fatalf("unexpected text edit range start line number: got %d, want less than %d", start, lineCount)
@@ -536,7 +536,7 @@ func main() {
}
env.AcceptCompletion("main.go", pos, completions.Items[0])
env.Await(env.DoneWithChange())
- got := env.Editor.BufferText("main.go")
+ got := env.BufferText("main.go")
want := "package main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"math\"\r\n)\r\n\r\nfunc main() {\r\n\tfmt.Println(\"a\")\r\n\tmath.Sqrt(${1:})\r\n}\r\n"
if got != want {
t.Errorf("unimported completion: got %q, want %q", got, want)
@@ -674,7 +674,7 @@ $0
env.AcceptCompletion("foo_test.go", pos, completions.Items[0])
env.Await(env.DoneWithChange())
- if buf := env.Editor.BufferText("foo_test.go"); buf != tst.after {
+ if buf := env.BufferText("foo_test.go"); buf != tst.after {
t.Errorf("incorrect completion: got %q, want %q", buf, tst.after)
}
}