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

Side by Side Diff: common/proto/google/descriptor/util_test.go

Issue 1587323003: client/cmd/rpc: RPC CLI (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@discovery
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
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 descriptor
6
7 import (
8 "testing"
9
10 "io/ioutil"
11
12 "github.com/golang/protobuf/proto"
13 . "github.com/smartystreets/goconvey/convey"
14 )
15
16 func TestUtil(t *testing.T) {
17 t.Parallel()
18
19 Convey("Util", t, func() {
20
21 descFileBytes, err := ioutil.ReadFile("util_test.desc")
22 So(err, ShouldBeNil)
23
24 var desc FileDescriptorSet
25 err = proto.Unmarshal(descFileBytes, &desc)
26 So(err, ShouldBeNil)
27
28 So(desc.File, ShouldHaveLength, 1)
29 file := desc.File[0]
30
31 Convey("Resolve works", func() {
32 names := []string{
33 "pkg.E1",
34 "pkg.E1.V0",
35
36 "pkg.M1",
37 "pkg.M1.f1",
38
39 "pkg.M2.f1",
40 "pkg.M2.f2",
41
42 "pkg.M3.O1",
43 "pkg.M3.f1",
44 "pkg.M3.O2",
45
46 "pkg.S1",
47 "pkg.S1.R1",
48 "pkg.S2.R2",
49
50 "pkg.NestedMessageParent",
51 "pkg.NestedMessageParent.NestedMessage",
52 "pkg.NestedMessageParent.NestedMessage.f1",
53 "pkg.NestedMessageParent.NestedEnum",
54 "pkg.NestedMessageParent.NestedEnum.V0",
55 }
56 for _, n := range names {
57 Convey(n, func() {
58 actualFile, obj, _ := desc.Resolve(n)
59 So(actualFile, ShouldEqual, file)
60 So(obj, ShouldNotBeNil)
61 })
62 }
63
64 Convey("wrong name", func() {
65 actualFile, obj, path := desc.Resolve("foo")
66 So(actualFile, ShouldBeNil)
67 So(obj, ShouldBeNil)
68 So(path, ShouldBeNil)
69 })
70 })
71 })
72 }
OLDNEW
« no previous file with comments | « common/proto/google/descriptor/util_test.desc ('k') | common/proto/google/descriptor/util_test.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698