| 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 "math" | 8 "math" |
| 9 "testing" | 9 "testing" |
| 10 "time" | 10 "time" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 pv := MkProperty(19) | 46 pv := MkProperty(19) |
| 47 So(pv.Value(), ShouldHaveSameTypeAs, int
64(19)) | 47 So(pv.Value(), ShouldHaveSameTypeAs, int
64(19)) |
| 48 So(pv.Value(), ShouldEqual, 19) | 48 So(pv.Value(), ShouldEqual, 19) |
| 49 So(pv.IndexSetting(), ShouldEqual, Shoul
dIndex) | 49 So(pv.IndexSetting(), ShouldEqual, Shoul
dIndex) |
| 50 So(pv.Type().String(), ShouldEqual, "PTI
nt") | 50 So(pv.Type().String(), ShouldEqual, "PTI
nt") |
| 51 }) | 51 }) |
| 52 Convey("bool (true)", func() { | 52 Convey("bool (true)", func() { |
| 53 pv := MkProperty(mybool(true)) | 53 pv := MkProperty(mybool(true)) |
| 54 So(pv.Value(), ShouldBeTrue) | 54 So(pv.Value(), ShouldBeTrue) |
| 55 So(pv.IndexSetting(), ShouldEqual, Shoul
dIndex) | 55 So(pv.IndexSetting(), ShouldEqual, Shoul
dIndex) |
| 56 » » » » » So(pv.Type().String(), ShouldEqual, "PTB
oolTrue") | 56 » » » » » So(pv.Type().String(), ShouldEqual, "PTB
ool") |
| 57 }) | 57 }) |
| 58 Convey("string", func() { | 58 Convey("string", func() { |
| 59 pv := MkProperty(mystring("sup")) | 59 pv := MkProperty(mystring("sup")) |
| 60 So(pv.Value(), ShouldEqual, "sup") | 60 So(pv.Value(), ShouldEqual, "sup") |
| 61 So(pv.IndexSetting(), ShouldEqual, Shoul
dIndex) | 61 So(pv.IndexSetting(), ShouldEqual, Shoul
dIndex) |
| 62 So(pv.Type().String(), ShouldEqual, "PTS
tring") | 62 So(pv.Type().String(), ShouldEqual, "PTS
tring") |
| 63 }) | 63 }) |
| 64 Convey("blobstore.Key is distinquished", func()
{ | 64 Convey("blobstore.Key is distinquished", func()
{ |
| 65 pv := MkProperty(blobstore.Key("sup")) | 65 pv := MkProperty(blobstore.Key("sup")) |
| 66 So(pv.Value(), ShouldEqual, blobstore.Ke
y("sup")) | 66 So(pv.Value(), ShouldEqual, blobstore.Ke
y("sup")) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 }) | 109 }) |
| 110 Convey("time gets rounded", func() { | 110 Convey("time gets rounded", func() { |
| 111 pv := Property{} | 111 pv := Property{} |
| 112 now := time.Now().In(time.UTC) | 112 now := time.Now().In(time.UTC) |
| 113 now = now.Round(time.Microsecond).Add(time.Nanos
econd * 313) | 113 now = now.Round(time.Microsecond).Add(time.Nanos
econd * 313) |
| 114 pv.SetValue(now, ShouldIndex) | 114 pv.SetValue(now, ShouldIndex) |
| 115 So(pv.Value(), ShouldHappenBefore, now) | 115 So(pv.Value(), ShouldHappenBefore, now) |
| 116 So(pv.IndexSetting(), ShouldEqual, ShouldIndex) | 116 So(pv.IndexSetting(), ShouldEqual, ShouldIndex) |
| 117 So(pv.Type().String(), ShouldEqual, "PTTime") | 117 So(pv.Type().String(), ShouldEqual, "PTTime") |
| 118 }) | 118 }) |
| 119 » » » Convey("[]byte coerces IndexSetting", func() { | 119 » » » Convey("[]byte allows IndexSetting", func() { |
| 120 pv := Property{} | 120 pv := Property{} |
| 121 pv.SetValue([]byte("hello"), ShouldIndex) | 121 pv.SetValue([]byte("hello"), ShouldIndex) |
| 122 So(pv.Value(), ShouldResemble, []byte("hello")) | 122 So(pv.Value(), ShouldResemble, []byte("hello")) |
| 123 So(pv.IndexSetting(), ShouldEqual, NoIndex) | |
| 124 So(pv.Type().String(), ShouldEqual, "PTBytes") | |
| 125 }) | |
| 126 Convey("ByteString allows !IndexSetting", func() { | |
| 127 pv := Property{} | |
| 128 pv.SetValue(ByteString("hello"), ShouldIndex) | |
| 129 So(pv.Value(), ShouldResemble, ByteString("hello
")) | |
| 130 So(pv.IndexSetting(), ShouldEqual, ShouldIndex) | 123 So(pv.IndexSetting(), ShouldEqual, ShouldIndex) |
| 131 So(pv.Type().String(), ShouldEqual, "PTBytes") | 124 So(pv.Type().String(), ShouldEqual, "PTBytes") |
| 132 }) | 125 }) |
| 133 }) | 126 }) |
| 134 }) | 127 }) |
| 135 } | 128 } |
| 136 | 129 |
| 137 func TestDSPropertyMapImpl(t *testing.T) { | 130 func TestDSPropertyMapImpl(t *testing.T) { |
| 138 t.Parallel() | 131 t.Parallel() |
| 139 | 132 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 171 |
| 179 Convey("weird value", func() { | 172 Convey("weird value", func() { |
| 180 pm := PropertyMap{} | 173 pm := PropertyMap{} |
| 181 err := pm.SetMeta("sup", complex(100, 20
)) | 174 err := pm.SetMeta("sup", complex(100, 20
)) |
| 182 So(err.Error(), ShouldContainSubstring,
"bad type") | 175 So(err.Error(), ShouldContainSubstring,
"bad type") |
| 183 }) | 176 }) |
| 184 }) | 177 }) |
| 185 }) | 178 }) |
| 186 }) | 179 }) |
| 187 } | 180 } |
| OLD | NEW |