internal/mcp: implement roots
Add support for roots. Change-Id: Ia50abc88f0047238272d698f30ce615b1a8fd486 Reviewed-on: https://go-review.googlesource.com/c/tools/+/671360 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sam Thanawalla <samthanawalla@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
cbb874302f
commit
5004d3e1bb
1 changed files with 133 additions and 28 deletions
|
|
@ -63,7 +63,7 @@ func TestEndToEnd(t *testing.T) {
|
|||
)
|
||||
|
||||
// Connect the server.
|
||||
cc, err := s.Connect(ctx, st, nil)
|
||||
sc, err := s.Connect(ctx, st, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -75,13 +75,14 @@ func TestEndToEnd(t *testing.T) {
|
|||
var clientWG sync.WaitGroup
|
||||
clientWG.Add(1)
|
||||
go func() {
|
||||
if err := cc.Wait(); err != nil {
|
||||
if err := sc.Wait(); err != nil {
|
||||
t.Errorf("server failed: %v", err)
|
||||
}
|
||||
clientWG.Done()
|
||||
}()
|
||||
|
||||
c := NewClient("testClient", "v1.0.0", ct, nil)
|
||||
c.AddRoots(protocol.Root{URI: "file:///root"})
|
||||
|
||||
// Connect the client.
|
||||
if err := c.Start(ctx); err != nil {
|
||||
|
|
@ -182,6 +183,13 @@ func TestEndToEnd(t *testing.T) {
|
|||
t.Errorf("tools/call 'fail' mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
|
||||
rootRes, err := sc.ListRoots(ctx, &protocol.ListRootsParams{})
|
||||
gotRoots := rootRes.Roots
|
||||
wantRoots := slices.Collect(c.roots.all())
|
||||
if diff := cmp.Diff(wantRoots, gotRoots); diff != "" {
|
||||
t.Errorf("roots/list mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
|
||||
// Disconnect.
|
||||
c.Close()
|
||||
clientWG.Wait()
|
||||
|
|
|
|||
Loading…
Reference in a new issue