mirror of
https://github.com/golang/go
synced 2024-11-05 23:16:11 -07:00
1fc30e1f4c
In an effort to be idiomatic, I made the regtest func signature func(context.Context, testing.T, *Env), despite the fact that Env already has a Context and a T. This just ended up causing more confusion, as it's not clear which Context or T to use. Remove this and just use the fields on Env. Change-Id: I54da1fdfe6ce17a67601b2af8640d4d2ea676e8c Reviewed-on: https://go-review.googlesource.com/c/tools/+/225157 Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
44 lines
916 B
Go
44 lines
916 B
Go
// 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 (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"golang.org/x/tools/internal/lsp/protocol"
|
|
)
|
|
|
|
const simpleProgram = `
|
|
-- go.mod --
|
|
module mod
|
|
|
|
go 1.12
|
|
-- main.go --
|
|
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
fmt.Println("Hello World.")
|
|
}`
|
|
|
|
func TestHoverSerialization(t *testing.T) {
|
|
runner.Run(t, simpleProgram, func(env *Env) {
|
|
// Hover on an empty line.
|
|
params := protocol.HoverParams{}
|
|
params.TextDocument.URI = env.W.URI("main.go")
|
|
params.Position.Line = 3
|
|
params.Position.Character = 0
|
|
var resp json.RawMessage
|
|
if err := env.Conn.Call(env.Ctx, "textDocument/hover", ¶ms, &resp); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(string(resp)) > 0 {
|
|
t.Errorf("got non-empty response for empty hover: %v", string(resp))
|
|
}
|
|
})
|
|
}
|