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

Side by Side Diff: common/proto/google/descutil/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
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package descriptor 5 package descutil
6 6
7 import ( 7 import (
8 "testing" 8 "testing"
9 9
10 "io/ioutil" 10 "io/ioutil"
11 11
12 "github.com/golang/protobuf/proto" 12 "github.com/golang/protobuf/proto"
13 . "github.com/smartystreets/goconvey/convey" 13 . "github.com/smartystreets/goconvey/convey"
14 pb "google.golang.org/genproto/protobuf"
14 ) 15 )
15 16
16 func TestUtil(t *testing.T) { 17 func TestUtil(t *testing.T) {
17 t.Parallel() 18 t.Parallel()
18 19
19 Convey("Util", t, func() { 20 Convey("Util", t, func() {
20 descFileBytes, err := ioutil.ReadFile("util_test.desc") 21 descFileBytes, err := ioutil.ReadFile("util_test.desc")
21 So(err, ShouldBeNil) 22 So(err, ShouldBeNil)
22 23
23 » » var desc FileDescriptorSet 24 » » var desc pb.FileDescriptorSet
24 err = proto.Unmarshal(descFileBytes, &desc) 25 err = proto.Unmarshal(descFileBytes, &desc)
25 So(err, ShouldBeNil) 26 So(err, ShouldBeNil)
26 27
27 » » So(desc.File, ShouldHaveLength, 2) 28 » » So(desc.File, ShouldHaveLength, 1)
28 » » file := desc.File[1] 29 » » file := desc.File[0]
29 » » So(file.GetName(), ShouldEqual, "github.com/luci/luci-go/common/ proto/google/descriptor/util_test.proto") 30 » » So(file.GetName(), ShouldEqual, "github.com/luci/luci-go/common/ proto/google/descutil/util_test.proto")
30 31
31 Convey("Resolve works", func() { 32 Convey("Resolve works", func() {
32 names := []string{ 33 names := []string{
33 » » » » "pkg.E1", 34 » » » » "descutil.E1",
34 » » » » "pkg.E1.V0", 35 » » » » "descutil.E1.V0",
35 36
36 » » » » "pkg.M1", 37 » » » » "descutil.M1",
37 » » » » "pkg.M1.f1", 38 » » » » "descutil.M1.f1",
38 39
39 » » » » "pkg.M2.f1", 40 » » » » "descutil.M2.f1",
40 » » » » "pkg.M2.f2", 41 » » » » "descutil.M2.f2",
41 42
42 » » » » "pkg.M3.O1", 43 » » » » "descutil.M3.O1",
43 » » » » "pkg.M3.f1", 44 » » » » "descutil.M3.f1",
44 » » » » "pkg.M3.O2", 45 » » » » "descutil.M3.O2",
45 46
46 » » » » "pkg.S1", 47 » » » » "descutil.S1",
47 » » » » "pkg.S1.R1", 48 » » » » "descutil.S1.R1",
48 » » » » "pkg.S2.R2", 49 » » » » "descutil.S2.R2",
49 50
50 » » » » "pkg.NestedMessageParent", 51 » » » » "descutil.NestedMessageParent",
51 » » » » "pkg.NestedMessageParent.NestedMessage", 52 » » » » "descutil.NestedMessageParent.NestedMessage",
52 » » » » "pkg.NestedMessageParent.NestedMessage.f1", 53 » » » » "descutil.NestedMessageParent.NestedMessage.f1",
53 » » » » "pkg.NestedMessageParent.NestedEnum", 54 » » » » "descutil.NestedMessageParent.NestedEnum",
54 » » » » "pkg.NestedMessageParent.NestedEnum.V0", 55 » » » » "descutil.NestedMessageParent.NestedEnum.V0",
55 } 56 }
56 for _, n := range names { 57 for _, n := range names {
57 Convey(n, func() { 58 Convey(n, func() {
58 » » » » » actualFile, obj, _ := desc.Resolve(n) 59 » » » » » actualFile, obj, _ := Resolve(&desc, n)
59 So(actualFile, ShouldEqual, file) 60 So(actualFile, ShouldEqual, file)
60 So(obj, ShouldNotBeNil) 61 So(obj, ShouldNotBeNil)
61 }) 62 })
62 } 63 }
63 64
64 Convey("wrong name", func() { 65 Convey("wrong name", func() {
65 » » » » actualFile, obj, path := desc.Resolve("foo") 66 » » » » actualFile, obj, path := Resolve(&desc, "foo")
66 So(actualFile, ShouldBeNil) 67 So(actualFile, ShouldBeNil)
67 So(obj, ShouldBeNil) 68 So(obj, ShouldBeNil)
68 So(path, ShouldBeNil) 69 So(path, ShouldBeNil)
69 }) 70 })
70 }) 71 })
71 }) 72 })
72 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698