OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package datastore | 5 package datastore |
6 | 6 |
7 import ( | 7 import ( |
8 "testing" | 8 "testing" |
9 | 9 |
10 . "github.com/smartystreets/goconvey/convey" | 10 . "github.com/smartystreets/goconvey/convey" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 m := mmg.GetSingle(10) | 25 m := mmg.GetSingle(10) |
26 val, err = m.GetMeta("hi") | 26 val, err = m.GetMeta("hi") |
27 So(err, ShouldEqual, ErrMetaFieldUnset) | 27 So(err, ShouldEqual, ErrMetaFieldUnset) |
28 So(val, ShouldBeNil) | 28 So(val, ShouldBeNil) |
29 So(m.GetMetaDefault("hi", "value"), ShouldEqual, "value"
) | 29 So(m.GetMetaDefault("hi", "value"), ShouldEqual, "value"
) |
30 }) | 30 }) |
31 | 31 |
32 Convey("stuff", func() { | 32 Convey("stuff", func() { |
33 pmaps := []PropertyMap{{}, nil, {}} | 33 pmaps := []PropertyMap{{}, nil, {}} |
34 » » » pmaps[0].SetMeta("hi", "thing") | 34 » » » So(pmaps[0].SetMeta("hi", "thing"), ShouldBeNil) |
35 » » » pmaps[2].SetMeta("key", 100) | 35 » » » So(pmaps[2].SetMeta("key", 100), ShouldBeNil) |
36 mmg := NewMultiMetaGetter(pmaps) | 36 mmg := NewMultiMetaGetter(pmaps) |
37 | 37 |
38 // oob is OK | 38 // oob is OK |
39 So(mmg.GetMetaDefault(7, "hi", "value"), ShouldEqual, "v
alue") | 39 So(mmg.GetMetaDefault(7, "hi", "value"), ShouldEqual, "v
alue") |
40 | 40 |
41 // nil is OK | 41 // nil is OK |
42 So(mmg.GetMetaDefault(1, "key", true), ShouldEqual, true
) | 42 So(mmg.GetMetaDefault(1, "key", true), ShouldEqual, true
) |
43 | 43 |
44 val, err := mmg.GetMeta(0, "hi") | 44 val, err := mmg.GetMeta(0, "hi") |
45 So(err, ShouldBeNil) | 45 So(err, ShouldBeNil) |
46 So(val, ShouldEqual, "thing") | 46 So(val, ShouldEqual, "thing") |
47 | 47 |
48 So(mmg.GetMetaDefault(2, "key", 20), ShouldEqual, 100) | 48 So(mmg.GetMetaDefault(2, "key", 20), ShouldEqual, 100) |
49 }) | 49 }) |
50 }) | 50 }) |
51 } | 51 } |
OLD | NEW |