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

Unified Diff: impl/memory/datastore_test.go

Issue 2342063003: Differentiate between single- and multi- props. (Closed)
Patch Set: Slice is now always a clone. This is marginally worse performance, but a much safer UI. Created 4 years, 3 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 | « impl/memory/datastore_query_execution.go ('k') | impl/memory/race_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore_test.go
diff --git a/impl/memory/datastore_test.go b/impl/memory/datastore_test.go
index fa4dbefb7264e49e36af1d3b654e4b5d32f4a948..ebca2e71ec55d6a423ae722df2336dab0c6b1731 100644
--- a/impl/memory/datastore_test.go
+++ b/impl/memory/datastore_test.go
@@ -40,8 +40,9 @@ type Foo struct {
ID int64 `gae:"$id"`
Parent *dsS.Key `gae:"$parent"`
- Val int
- Name string
+ Val int
+ Name string
+ Multi []string
}
func TestDatastoreSingleReadWriter(t *testing.T) {
@@ -63,7 +64,7 @@ func TestDatastoreSingleReadWriter(t *testing.T) {
Convey("Can Put stuff", func() {
// with an incomplete key!
- f := &Foo{Val: 10}
+ f := &Foo{Val: 10, Multi: []string{"foo", "bar"}}
So(ds.Put(f), ShouldBeNil)
k := ds.KeyForObj(f)
So(k.String(), ShouldEqual, "dev~app::/Foo,1")
@@ -86,6 +87,20 @@ func TestDatastoreSingleReadWriter(t *testing.T) {
})
})
+ Convey("Can Get it back as a PropertyMap", func() {
+ pmap := dsS.PropertyMap{
+ "$id": propNI(1),
+ "$kind": propNI("Foo"),
+ }
+ So(ds.Get(pmap), ShouldBeNil)
+ So(pmap, ShouldResemble, dsS.PropertyMap{
+ "$id": propNI(1),
+ "$kind": propNI("Foo"),
+ "Name": prop(""),
+ "Val": prop(10),
+ "Multi": dsS.PropertySlice{prop("foo"), prop("bar")},
+ })
+ })
Convey("Deleteing with a bogus key is bad", func() {
So(ds.Delete(ds.NewKey("Foo", "wat", 100, nil)), ShouldEqual, dsS.ErrInvalidKey)
})
@@ -152,9 +167,9 @@ func TestDatastoreSingleReadWriter(t *testing.T) {
for i, val := range vals {
So(val, ShouldResemble, dsS.PropertyMap{
- "Val": {dsS.MkProperty(10)},
- "Name": {dsS.MkProperty("")},
- "$key": {dsS.MkPropertyNI(keys[i])},
+ "Val": dsS.MkProperty(10),
+ "Name": dsS.MkProperty(""),
+ "$key": dsS.MkPropertyNI(keys[i]),
})
}
})
@@ -706,8 +721,8 @@ func TestNewDatastore(t *testing.T) {
So(ds.GetAll(dsS.NewQuery("Model").Project("Value"), &vals), ShouldBeNil)
So(len(vals), ShouldEqual, 2)
- So(vals[0]["Value"][0].Value(), ShouldEqual, 20)
- So(vals[1]["Value"][0].Value(), ShouldEqual, 30)
+ So(vals[0].Slice("Value")[0].Value(), ShouldEqual, 20)
+ So(vals[1].Slice("Value")[0].Value(), ShouldEqual, 30)
})
}
« no previous file with comments | « impl/memory/datastore_query_execution.go ('k') | impl/memory/race_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698