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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/proto/google/descriptor/util_test.go
diff --git a/common/proto/google/descriptor/util_test.go b/common/proto/google/descriptor/util_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..c63ac0777365d580f93c9c2c26d31770e159fcbe
--- /dev/null
+++ b/common/proto/google/descriptor/util_test.go
@@ -0,0 +1,72 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package descriptor
+
+import (
+ "testing"
+
+ "io/ioutil"
+
+ "github.com/golang/protobuf/proto"
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestUtil(t *testing.T) {
+ t.Parallel()
+
+ Convey("Util", t, func() {
+
+ descFileBytes, err := ioutil.ReadFile("util_test.desc")
+ So(err, ShouldBeNil)
+
+ var desc FileDescriptorSet
+ err = proto.Unmarshal(descFileBytes, &desc)
+ So(err, ShouldBeNil)
+
+ So(desc.File, ShouldHaveLength, 1)
+ file := desc.File[0]
+
+ Convey("Resolve works", func() {
+ names := []string{
+ "pkg.E1",
+ "pkg.E1.V0",
+
+ "pkg.M1",
+ "pkg.M1.f1",
+
+ "pkg.M2.f1",
+ "pkg.M2.f2",
+
+ "pkg.M3.O1",
+ "pkg.M3.f1",
+ "pkg.M3.O2",
+
+ "pkg.S1",
+ "pkg.S1.R1",
+ "pkg.S2.R2",
+
+ "pkg.NestedMessageParent",
+ "pkg.NestedMessageParent.NestedMessage",
+ "pkg.NestedMessageParent.NestedMessage.f1",
+ "pkg.NestedMessageParent.NestedEnum",
+ "pkg.NestedMessageParent.NestedEnum.V0",
+ }
+ for _, n := range names {
+ Convey(n, func() {
+ actualFile, obj, _ := desc.Resolve(n)
+ So(actualFile, ShouldEqual, file)
+ So(obj, ShouldNotBeNil)
+ })
+ }
+
+ Convey("wrong name", func() {
+ actualFile, obj, path := desc.Resolve("foo")
+ So(actualFile, ShouldBeNil)
+ So(obj, ShouldBeNil)
+ So(path, ShouldBeNil)
+ })
+ })
+ })
+}
« 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