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

Side by Side Diff: client/flagpb/unmarshal_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 flagpb 5 package flagpb
6 6
7 import ( 7 import (
8 "io/ioutil" 8 "io/ioutil"
9 "testing" 9 "testing"
10 10
11 "github.com/golang/protobuf/proto" 11 "github.com/golang/protobuf/proto"
12 » "github.com/luci/luci-go/common/proto/google/descriptor" 12 » "google.golang.org/genproto/protobuf"
13
14 » "github.com/luci/luci-go/common/proto/google/descutil"
13 15
14 . "github.com/luci/luci-go/common/testing/assertions" 16 . "github.com/luci/luci-go/common/testing/assertions"
15 . "github.com/smartystreets/goconvey/convey" 17 . "github.com/smartystreets/goconvey/convey"
16 ) 18 )
17 19
18 func TestUnmarshal(t *testing.T) { 20 func TestUnmarshal(t *testing.T) {
19 t.Parallel() 21 t.Parallel()
20 22
21 Convey("Unmarshal", t, func() { 23 Convey("Unmarshal", t, func() {
22 descFileBytes, err := ioutil.ReadFile("unmarshal_test.desc") 24 descFileBytes, err := ioutil.ReadFile("unmarshal_test.desc")
23 So(err, ShouldBeNil) 25 So(err, ShouldBeNil)
24 26
25 var desc descriptor.FileDescriptorSet 27 var desc descriptor.FileDescriptorSet
26 err = proto.Unmarshal(descFileBytes, &desc) 28 err = proto.Unmarshal(descFileBytes, &desc)
27 So(err, ShouldBeNil) 29 So(err, ShouldBeNil)
28 30
29 resolver := NewResolver(&desc) 31 resolver := NewResolver(&desc)
30 32
31 resolveMsg := func(name string) *descriptor.DescriptorProto { 33 resolveMsg := func(name string) *descriptor.DescriptorProto {
32 » » » _, obj, _ := desc.Resolve("flagpb." + name) 34 » » » _, obj, _ := descutil.Resolve(&desc, "flagpb."+name)
33 So(obj, ShouldNotBeNil) 35 So(obj, ShouldNotBeNil)
34 return obj.(*descriptor.DescriptorProto) 36 return obj.(*descriptor.DescriptorProto)
35 } 37 }
36 38
37 unmarshalOK := func(typeName string, args ...string) map[string] interface{} { 39 unmarshalOK := func(typeName string, args ...string) map[string] interface{} {
38 msg, err := UnmarshalUntyped(args, resolveMsg(typeName), resolver) 40 msg, err := UnmarshalUntyped(args, resolveMsg(typeName), resolver)
39 So(err, ShouldBeNil) 41 So(err, ShouldBeNil)
40 return msg 42 return msg
41 } 43 }
42 44
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 So(unmarshalOK("MapContainer", "-sm1.x.s", "a", "-sm1.y.s", "b"), ShouldResemble, msg( 209 So(unmarshalOK("MapContainer", "-sm1.x.s", "a", "-sm1.y.s", "b"), ShouldResemble, msg(
208 "sm1", msg( 210 "sm1", msg(
209 "x", msg("s", "a"), 211 "x", msg("s", "a"),
210 "y", msg("s", "b"), 212 "y", msg("s", "b"),
211 ), 213 ),
212 )) 214 ))
213 }) 215 })
214 }) 216 })
215 }) 217 })
216 } 218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698