github.com/v2fly/tools@v0.100.0/internal/lsp/cmd/test/signature.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  	"fmt"
     9  	"testing"
    10  
    11  	"github.com/v2fly/tools/internal/lsp/protocol"
    12  	"github.com/v2fly/tools/internal/span"
    13  )
    14  
    15  func (r *runner) SignatureHelp(t *testing.T, spn span.Span, want *protocol.SignatureHelp) {
    16  	uri := spn.URI()
    17  	filename := uri.Filename()
    18  	target := filename + fmt.Sprintf(":%v:%v", spn.Start().Line(), spn.Start().Column())
    19  	got, _ := r.NormalizeGoplsCmd(t, "signature", target)
    20  	if want == nil {
    21  		if got != "" {
    22  			t.Fatalf("want nil, but got %s", got)
    23  		}
    24  		return
    25  	}
    26  	goldenTag := want.Signatures[0].Label + "-signature"
    27  	expect := string(r.data.Golden(goldenTag, filename, func() ([]byte, error) {
    28  		return []byte(got), nil
    29  	}))
    30  	if expect != got {
    31  		t.Errorf("signature failed for %s expected:\n%q\ngot:\n%q'", filename, expect, got)
    32  	}
    33  }