1
0
mirror of https://github.com/golang/go synced 2024-11-05 23:36:12 -07:00
go/internal/lsp/regtest/serialization_test.go
Rob Findley 8cb32c4661 internal/lsp/regtest: clean up module names and include github issues
A couple small improvements for regtests:
 - module names fixed to include a '.'. This was fixed for diagnostic
   tests already.
 - For regtests that were written to exercise specifig github issues,
   include the issue number in the test name.

Change-Id: I67da6d78dc166e854d2543cf63dac382202f9dbc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/226844
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-04-02 21:48:35 +00:00

44 lines
920 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.com
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", &params, &resp); err != nil {
t.Fatal(err)
}
if len(string(resp)) > 0 {
t.Errorf("got non-empty response for empty hover: %v", string(resp))
}
})
}