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

Side by Side Diff: impl/memory/datastore_test.go

Issue 2011773002: datastore: variadic Get, Put, Exists, Delete. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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 memory 5 package memory
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "testing" 9 "testing"
10 "time" 10 "time"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 Convey("Deleteing a DNE entity is fine", func() { 92 Convey("Deleteing a DNE entity is fine", func() {
93 So(ds.Delete(ds.NewKey("Foo", "wat", 0, nil)), S houldBeNil) 93 So(ds.Delete(ds.NewKey("Foo", "wat", 0, nil)), S houldBeNil)
94 }) 94 })
95 95
96 Convey("Deleting entities from a nonexistant namespace w orks", func() { 96 Convey("Deleting entities from a nonexistant namespace w orks", func() {
97 aid := infoS.Get(c).FullyQualifiedAppID() 97 aid := infoS.Get(c).FullyQualifiedAppID()
98 keys := make([]*dsS.Key, 10) 98 keys := make([]*dsS.Key, 10)
99 for i := range keys { 99 for i := range keys {
100 keys[i] = ds.MakeKey(aid, "noexist", "Ki nd", i+1) 100 keys[i] = ds.MakeKey(aid, "noexist", "Ki nd", i+1)
101 } 101 }
102 » » » » So(ds.DeleteMulti(keys), ShouldBeNil) 102 » » » » So(ds.DeleteMulti(keys...), ShouldBeNil)
103 count := 0 103 count := 0
104 So(ds.Raw().DeleteMulti(keys, func(err error) er ror { 104 So(ds.Raw().DeleteMulti(keys, func(err error) er ror {
105 count++ 105 count++
106 So(err, ShouldBeNil) 106 So(err, ShouldBeNil)
107 return nil 107 return nil
108 }), ShouldBeNil) 108 }), ShouldBeNil)
109 So(count, ShouldEqual, len(keys)) 109 So(count, ShouldEqual, len(keys))
110 }) 110 })
111 111
112 Convey("with multiple puts", func() { 112 Convey("with multiple puts", func() {
113 So(testGetMeta(c, k), ShouldEqual, 1) 113 So(testGetMeta(c, k), ShouldEqual, 1)
114 114
115 foos := make([]Foo, 10) 115 foos := make([]Foo, 10)
116 for i := range foos { 116 for i := range foos {
117 foos[i].Val = 10 117 foos[i].Val = 10
118 foos[i].Parent = k 118 foos[i].Parent = k
119 } 119 }
120 So(ds.PutMulti(foos), ShouldBeNil) 120 So(ds.PutMulti(foos), ShouldBeNil)
121 So(testGetMeta(c, k), ShouldEqual, 11) 121 So(testGetMeta(c, k), ShouldEqual, 11)
122 122
123 keys := make([]*dsS.Key, len(foos)) 123 keys := make([]*dsS.Key, len(foos))
124 for i, f := range foos { 124 for i, f := range foos {
125 keys[i] = ds.KeyForObj(&f) 125 keys[i] = ds.KeyForObj(&f)
126 } 126 }
127 127
128 Convey("ensure that group versions persist acros s deletes", func() { 128 Convey("ensure that group versions persist acros s deletes", func() {
129 » » » » » So(ds.DeleteMulti(append(keys, k)), Shou ldBeNil) 129 » » » » » So(ds.DeleteMulti(append(keys, k)...), S houldBeNil)
130 130
131 ds.Testable().CatchupIndexes() 131 ds.Testable().CatchupIndexes()
132 132
133 count := 0 133 count := 0
134 So(ds.Run(dsS.NewQuery(""), func(_ *dsS. Key) { 134 So(ds.Run(dsS.NewQuery(""), func(_ *dsS. Key) {
135 count++ 135 count++
136 }), ShouldBeNil) 136 }), ShouldBeNil)
137 So(count, ShouldEqual, 3) 137 So(count, ShouldEqual, 3)
138 138
139 So(testGetMeta(c, k), ShouldEqual, 22) 139 So(testGetMeta(c, k), ShouldEqual, 22)
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 // Add "foos" to a new namespace, then confirm that it g ets indexed. 756 // Add "foos" to a new namespace, then confirm that it g ets indexed.
757 So(dsS.Get(infoS.Get(ctx).MustNamespace("qux")).PutMulti (foos), ShouldBeNil) 757 So(dsS.Get(infoS.Get(ctx).MustNamespace("qux")).PutMulti (foos), ShouldBeNil)
758 dsS.Get(ctx).Testable().CatchupIndexes() 758 dsS.Get(ctx).Testable().CatchupIndexes()
759 759
760 results = nil 760 results = nil
761 So(dsS.Get(infoS.Get(ctx).MustNamespace("qux")).GetAll(q , &results), ShouldBeNil) 761 So(dsS.Get(infoS.Get(ctx).MustNamespace("qux")).GetAll(q , &results), ShouldBeNil)
762 So(len(results), ShouldEqual, 2) 762 So(len(results), ShouldEqual, 2)
763 }) 763 })
764 }) 764 })
765 } 765 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698