| 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)
|
| + })
|
| + })
|
| +}
|
|
|