1
0
mirror of https://github.com/golang/go synced 2024-10-01 04:08:32 -06:00
go/internal/lsp/regtest/serialization_test.go
Rob Findley 9a0fabac01 internal/lsp: fix errors found by staticcheck
While experimenting with different static analysis on x/tools, I noticed
that there are many actionable diagnostics found by staticcheck. Fix the
ones that were not false positives.

Change-Id: I0b68cf1f636b57b557db879fad84fff9b7237a89
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222248
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-03-19 19:20:54 +00:00

45 lines
958 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 (
"context"
"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(ctx context.Context, t *testing.T, 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(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))
}
})
}