Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: server/discovery/internal/testservices/discovery_test.go

Issue 1571393006: server/discovery: add discovery service (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@prpc-server
Patch Set: rebased Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « server/discovery/generate.go ('k') | server/discovery/internal/testservices/generate.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package testservices
6
7 // This test is not in discovery because it needs to a test services
8 // in different directories.
9 // However, a generated service depends on server/discovery
10 // and a test in server/discovery depends on the service.
11 // This creates a a cyclic import.
12 // To break the cycle, we move this test from server/discovery.
13
14 import (
15 "testing"
16
17 "github.com/golang/protobuf/proto"
18 "golang.org/x/net/context"
19
20 "github.com/luci/luci-go/common/proto/google/descriptor"
21 "github.com/luci/luci-go/server/discovery"
22
23 . "github.com/luci/luci-go/common/testing/assertions"
24 . "github.com/smartystreets/goconvey/convey"
25 )
26
27 // force test services registration.
28 var _ = CalcServer(nil)
29
30 func TestDiscovery(t *testing.T) {
31 Convey("Discovery", t, func() {
32
33 server, err := discovery.New(
34 "discovery.Discovery",
35 "testservices.Greeter",
36 "testservices.Calc",
37 )
38 So(err, ShouldBeNil)
39
40 c := context.Background()
41 res, err := server.Describe(c, nil)
42 So(err, ShouldBeNil)
43
44 So(res.Services, ShouldResembleV, []string{
45 "discovery.Discovery",
46 "testservices.Greeter",
47 "testservices.Calc",
48 })
49
50 desc := &descriptor.FileDescriptorSet{}
51 err = proto.Unmarshal(res.FileDescriptionSet, desc)
52 So(err, ShouldBeNil)
53
54 // this checks that file deduplication actually works.
55 So(len(desc.File), ShouldEqual, 2)
56
57 discovery := desc.FindService("discovery.Discovery")
58 So(discovery, ShouldNotBeNil)
59
60 calc := desc.FindService("testservices.Calc")
61 So(calc, ShouldNotBeNil)
62
63 serviceDesc := desc.FindService("testservices.Greeter")
64 So(serviceDesc, ShouldNotBeNil)
65
66 sayHelloDesc := serviceDesc.FindMethod("SayHello")
67 So(sayHelloDesc, ShouldNotBeNil)
68
69 So(sayHelloDesc.GetInputType(), ShouldEqual, ".testservices.Hell oRequest")
70 helloReq := desc.FindMessage("testservices.HelloRequest")
71 So(helloReq, ShouldNotBeNil)
72 So(helloReq.Field, ShouldHaveLength, 1)
73 So(helloReq.Field[0].GetName(), ShouldEqual, "name")
74 So(helloReq.Field[0].GetType(), ShouldEqual, descriptor.FieldDes criptorProto_TYPE_STRING)
75 })
76 }
OLDNEW
« no previous file with comments | « server/discovery/generate.go ('k') | server/discovery/internal/testservices/generate.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698