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 // adapted from github.com/golang/appengine/datastore | 5 // adapted from github.com/golang/appengine/datastore |
6 | 6 |
7 package datastore | 7 package datastore |
8 | 8 |
9 import ( | 9 import ( |
10 "bytes" | 10 "bytes" |
(...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 type OKDefaults struct { | 1792 type OKDefaults struct { |
1793 When string `gae:"$when,tomorrow"` | 1793 When string `gae:"$when,tomorrow"` |
1794 Amount int64 `gae:"$amt,100"` | 1794 Amount int64 `gae:"$amt,100"` |
1795 } | 1795 } |
1796 pls := GetPLS(&OKDefaults{}) | 1796 pls := GetPLS(&OKDefaults{}) |
1797 pm, err := pls.Save(true) | 1797 pm, err := pls.Save(true) |
1798 So(err, ShouldBeNil) | 1798 So(err, ShouldBeNil) |
1799 So(pm, ShouldResemble, PropertyMap{ | 1799 So(pm, ShouldResemble, PropertyMap{ |
1800 "$when": {mpNI("tomorrow")}, | 1800 "$when": {mpNI("tomorrow")}, |
1801 "$amt": {mpNI(100)}, | 1801 "$amt": {mpNI(100)}, |
| 1802 "$kind": {mpNI("OKDefaults")}, |
1802 }) | 1803 }) |
1803 | 1804 |
1804 v, err := pm.GetMeta("when") | 1805 v, err := pm.GetMeta("when") |
1805 So(err, ShouldBeNil) | 1806 So(err, ShouldBeNil) |
1806 So(v, ShouldEqual, "tomorrow") | 1807 So(v, ShouldEqual, "tomorrow") |
1807 | 1808 |
1808 v, err = pm.GetMeta("amt") | 1809 v, err = pm.GetMeta("amt") |
1809 So(err, ShouldBeNil) | 1810 So(err, ShouldBeNil) |
1810 So(v, ShouldEqual, int64(100)) | 1811 So(v, ShouldEqual, int64(100)) |
1811 }) | 1812 }) |
(...skipping 29 matching lines...) Expand all Loading... |
1841 | 1842 |
1842 Convey("Bad default meta type", func() { | 1843 Convey("Bad default meta type", func() { |
1843 type BadDefault struct { | 1844 type BadDefault struct { |
1844 Val time.Time `gae:"$meta,tomorrow"` | 1845 Val time.Time `gae:"$meta,tomorrow"` |
1845 } | 1846 } |
1846 pls := GetPLS(&BadDefault{}) | 1847 pls := GetPLS(&BadDefault{}) |
1847 So(pls.Problem().Error(), ShouldContainSubstring, "bad t
ype") | 1848 So(pls.Problem().Error(), ShouldContainSubstring, "bad t
ype") |
1848 }) | 1849 }) |
1849 }) | 1850 }) |
1850 } | 1851 } |
OLD | NEW |