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

Unified Diff: service/datastore/raw_interface_test.go

Issue 1270113002: Re-add metadata passthrough on Get operations (Closed) Base URL: https://github.com/luci/gae.git@fix_other_interfaces
Patch Set: cleanup Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « service/datastore/raw_interface.go ('k') | service/datastore/reflect.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/raw_interface_test.go
diff --git a/service/datastore/raw_interface_test.go b/service/datastore/raw_interface_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..8bfac8a42693e8945cd26acf2d69d61e4f7638d1
--- /dev/null
+++ b/service/datastore/raw_interface_test.go
@@ -0,0 +1,51 @@
+// Copyright 2015 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 datastore
+
+import (
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestMultiMetaGetter(t *testing.T) {
+ t.Parallel()
+
+ Convey("Test MultiMetaGetter", t, func() {
+ Convey("nil", func() {
+ mmg := NewMultiMetaGetter(nil)
+ val, err := mmg.GetMeta(7, "hi")
+ So(err, ShouldEqual, ErrMetaFieldUnset)
+ So(val, ShouldBeNil)
+
+ So(mmg.GetMetaDefault(7, "hi", "value"), ShouldEqual, "value")
+
+ m := mmg.GetSingle(10)
+ val, err = m.GetMeta("hi")
+ So(err, ShouldEqual, ErrMetaFieldUnset)
+ So(val, ShouldBeNil)
+ So(m.GetMetaDefault("hi", "value"), ShouldEqual, "value")
+ })
+
+ Convey("stuff", func() {
+ pmaps := []PropertyMap{{}, nil, {}}
+ pmaps[0].SetMeta("hi", "thing")
+ pmaps[2].SetMeta("key", 100)
+ mmg := NewMultiMetaGetter(pmaps)
+
+ // oob is OK
+ So(mmg.GetMetaDefault(7, "hi", "value"), ShouldEqual, "value")
+
+ // nil is OK
+ So(mmg.GetMetaDefault(1, "key", true), ShouldEqual, true)
+
+ val, err := mmg.GetMeta(0, "hi")
+ So(err, ShouldBeNil)
+ So(val, ShouldEqual, "thing")
+
+ So(mmg.GetMetaDefault(2, "key", 20), ShouldEqual, 100)
+ })
+ })
+}
« no previous file with comments | « service/datastore/raw_interface.go ('k') | service/datastore/reflect.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698