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

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

Issue 2219023003: Update APIs to use new Google cloud paths. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 4 years, 4 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 LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be 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 descFileBytes, err := ioutil.ReadFile("util_test.desc")
21 So(err, ShouldBeNil)
22
23 var desc FileDescriptorSet
24 err = proto.Unmarshal(descFileBytes, &desc)
25 So(err, ShouldBeNil)
26
27 So(desc.File, ShouldHaveLength, 2)
28 file := desc.File[1]
29 So(file.GetName(), ShouldEqual, "github.com/luci/luci-go/common/ proto/google/descriptor/util_test.proto")
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

Powered by Google App Engine
This is Rietveld 408576698