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

Unified Diff: service/rawdatastore/datastore_test.go

Issue 1259463002: Add BoolFlag for rawdatastore. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: improve error Created 5 years, 5 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/rawdatastore/datastore_impl.go ('k') | service/rawdatastore/properties.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/rawdatastore/datastore_test.go
diff --git a/service/rawdatastore/datastore_test.go b/service/rawdatastore/datastore_test.go
index 462fe7cfac382ea5e6c20ac429050da0031821b7..a96048c68914494bb80bbb0a95809abe7a72984e 100644
--- a/service/rawdatastore/datastore_test.go
+++ b/service/rawdatastore/datastore_test.go
@@ -1643,8 +1643,10 @@ func TestSpecial(t *testing.T) {
type OKDefaults struct {
When string `gae:"$when,tomorrow"`
Amount int64 `gae:"$amt,100"`
+ DoIt Toggle `gae:"$doit,on"`
}
- pls := GetPLS(&OKDefaults{})
+ okd := &OKDefaults{}
+ pls := GetPLS(okd)
So(pls.Problem(), ShouldBeNil)
v, err := pls.GetMeta("when")
@@ -1654,6 +1656,33 @@ func TestSpecial(t *testing.T) {
v, err = pls.GetMeta("amt")
So(err, ShouldBeNil)
So(v, ShouldEqual, int64(100))
+
+ So(okd.DoIt, ShouldEqual, Auto)
+ v, err = pls.GetMeta("doit")
+ So(err, ShouldBeNil)
+ So(v, ShouldBeTrue)
+
+ err = pls.SetMeta("doit", false)
+ So(err, ShouldBeNil)
+ v, err = pls.GetMeta("doit")
+ So(err, ShouldBeNil)
+ So(v, ShouldBeFalse)
+ So(okd.DoIt, ShouldEqual, Off)
+
+ err = pls.SetMeta("doit", true)
+ So(err, ShouldBeNil)
+ v, err = pls.GetMeta("doit")
+ So(err, ShouldBeNil)
+ So(v, ShouldBeTrue)
+ So(okd.DoIt, ShouldEqual, On)
+
+ Convey("Toggle fields REQUIRE a default", func() {
+ type BadToggle struct {
+ Bad Toggle `gae:"$wut"`
+ }
+ pls := GetPLS(&BadToggle{})
+ So(pls.Problem().Error(), ShouldContainSubstring, "bad/missing default")
+ })
})
Convey("meta fields can be saved", func() {
« no previous file with comments | « service/rawdatastore/datastore_impl.go ('k') | service/rawdatastore/properties.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698