github.com/v2fly/tools@v0.100.0/internal/lsp/cmd/test/links.go (about) 1 // Copyright 2019 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package cmdtest 6 7 import ( 8 "encoding/json" 9 "testing" 10 11 "github.com/v2fly/tools/internal/lsp/protocol" 12 "github.com/v2fly/tools/internal/lsp/tests" 13 "github.com/v2fly/tools/internal/span" 14 ) 15 16 func (r *runner) Link(t *testing.T, uri span.URI, wantLinks []tests.Link) { 17 m, err := r.data.Mapper(uri) 18 if err != nil { 19 t.Fatal(err) 20 } 21 out, _ := r.NormalizeGoplsCmd(t, "links", "-json", uri.Filename()) 22 var got []protocol.DocumentLink 23 err = json.Unmarshal([]byte(out), &got) 24 if err != nil { 25 t.Fatal(err) 26 } 27 if diff := tests.DiffLinks(m, wantLinks, got); diff != "" { 28 t.Error(diff) 29 } 30 }