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

Side by Side Diff: service/datastore/checkfilter_test.go

Issue 1521823003: Clean up callback interfaces. (Closed) Base URL: https://github.com/luci/gae.git@extra
Patch Set: fixins Created 5 years 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
« no previous file with comments | « impl/prod/raw_datastore.go ('k') | service/datastore/datastore.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // 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 "testing" 10 "testing"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 }) 43 })
44 44
45 Convey("Run", func() { 45 Convey("Run", func() {
46 So(rds.Run(nil, nil).Error(), ShouldContainSubstring, "q uery is nil") 46 So(rds.Run(nil, nil).Error(), ShouldContainSubstring, "q uery is nil")
47 fq, err := NewQuery("sup").Finalize() 47 fq, err := NewQuery("sup").Finalize()
48 So(err, ShouldBeNil) 48 So(err, ShouldBeNil)
49 49
50 So(rds.Run(fq, nil).Error(), ShouldContainSubstring, "ca llback is nil") 50 So(rds.Run(fq, nil).Error(), ShouldContainSubstring, "ca llback is nil")
51 hit := false 51 hit := false
52 So(func() { 52 So(func() {
53 » » » » So(rds.Run(fq, func(*Key, PropertyMap, CursorCB) bool { 53 » » » » So(rds.Run(fq, func(*Key, PropertyMap, CursorCB) error {
54 hit = true 54 hit = true
55 » » » » » return true 55 » » » » » return nil
56 }), ShouldBeNil) 56 }), ShouldBeNil)
57 }, ShouldPanic) 57 }, ShouldPanic)
58 So(hit, ShouldBeFalse) 58 So(hit, ShouldBeFalse)
59 }) 59 })
60 60
61 Convey("GetMulti", func() { 61 Convey("GetMulti", func() {
62 So(rds.GetMulti(nil, nil, nil), ShouldBeNil) 62 So(rds.GetMulti(nil, nil, nil), ShouldBeNil)
63 So(rds.GetMulti([]*Key{mkKey("", "", "", "")}, nil, nil) .Error(), ShouldContainSubstring, "is nil") 63 So(rds.GetMulti([]*Key{mkKey("", "", "", "")}, nil, nil) .Error(), ShouldContainSubstring, "is nil")
64 64
65 // this is in the wrong aid/ns 65 // this is in the wrong aid/ns
66 keys := []*Key{MakeKey("wut", "wrong", "Kind", 1)} 66 keys := []*Key{MakeKey("wut", "wrong", "Kind", 1)}
67 » » » So(rds.GetMulti(keys, nil, func(pm PropertyMap, err erro r) { 67 » » » So(rds.GetMulti(keys, nil, func(pm PropertyMap, err erro r) error {
68 So(pm, ShouldBeNil) 68 So(pm, ShouldBeNil)
69 So(err, ShouldEqual, ErrInvalidKey) 69 So(err, ShouldEqual, ErrInvalidKey)
70 return nil
70 }), ShouldBeNil) 71 }), ShouldBeNil)
71 72
72 keys[0] = mkKey("Kind", 1) 73 keys[0] = mkKey("Kind", 1)
73 hit := false 74 hit := false
74 So(func() { 75 So(func() {
75 » » » » So(rds.GetMulti(keys, nil, func(pm PropertyMap, err error) { 76 » » » » So(rds.GetMulti(keys, nil, func(pm PropertyMap, err error) error {
76 hit = true 77 hit = true
78 return nil
77 }), ShouldBeNil) 79 }), ShouldBeNil)
78 }, ShouldPanic) 80 }, ShouldPanic)
79 So(hit, ShouldBeFalse) 81 So(hit, ShouldBeFalse)
80 }) 82 })
81 83
82 Convey("PutMulti", func() { 84 Convey("PutMulti", func() {
83 keys := []*Key{} 85 keys := []*Key{}
84 vals := []PropertyMap{{}} 86 vals := []PropertyMap{{}}
85 So(rds.PutMulti(keys, vals, nil).Error(), 87 So(rds.PutMulti(keys, vals, nil).Error(),
86 ShouldContainSubstring, "mismatched keys/vals") 88 ShouldContainSubstring, "mismatched keys/vals")
87 So(rds.PutMulti(nil, nil, nil), ShouldBeNil) 89 So(rds.PutMulti(nil, nil, nil), ShouldBeNil)
88 90
89 keys = append(keys, mkKey("aid", "ns", "Wut", 0, "Kind", 0)) 91 keys = append(keys, mkKey("aid", "ns", "Wut", 0, "Kind", 0))
90 So(rds.PutMulti(keys, vals, nil).Error(), ShouldContainS ubstring, "callback is nil") 92 So(rds.PutMulti(keys, vals, nil).Error(), ShouldContainS ubstring, "callback is nil")
91 93
92 » » » So(rds.PutMulti(keys, vals, func(k *Key, err error) { 94 » » » So(rds.PutMulti(keys, vals, func(k *Key, err error) erro r {
93 So(k, ShouldBeNil) 95 So(k, ShouldBeNil)
94 So(err, ShouldEqual, ErrInvalidKey) 96 So(err, ShouldEqual, ErrInvalidKey)
97 return nil
95 }), ShouldBeNil) 98 }), ShouldBeNil)
96 99
97 keys = []*Key{mkKey("s~aid", "ns", "Kind", 0)} 100 keys = []*Key{mkKey("s~aid", "ns", "Kind", 0)}
98 vals = []PropertyMap{nil} 101 vals = []PropertyMap{nil}
99 » » » So(rds.PutMulti(keys, vals, func(k *Key, err error) { 102 » » » So(rds.PutMulti(keys, vals, func(k *Key, err error) erro r {
100 So(k, ShouldBeNil) 103 So(k, ShouldBeNil)
101 So(err.Error(), ShouldContainSubstring, "nil val s entry") 104 So(err.Error(), ShouldContainSubstring, "nil val s entry")
105 return nil
102 }), ShouldBeNil) 106 }), ShouldBeNil)
103 107
104 vals = []PropertyMap{{}} 108 vals = []PropertyMap{{}}
105 hit := false 109 hit := false
106 So(func() { 110 So(func() {
107 » » » » So(rds.PutMulti(keys, vals, func(k *Key, err err or) { 111 » » » » So(rds.PutMulti(keys, vals, func(k *Key, err err or) error {
108 hit = true 112 hit = true
113 return nil
109 }), ShouldBeNil) 114 }), ShouldBeNil)
110 }, ShouldPanic) 115 }, ShouldPanic)
111 So(hit, ShouldBeFalse) 116 So(hit, ShouldBeFalse)
112 }) 117 })
113 118
114 Convey("DeleteMulti", func() { 119 Convey("DeleteMulti", func() {
115 So(rds.DeleteMulti(nil, nil), ShouldBeNil) 120 So(rds.DeleteMulti(nil, nil), ShouldBeNil)
116 So(rds.DeleteMulti([]*Key{mkKey("", "", "", "")}, nil).E rror(), ShouldContainSubstring, "is nil") 121 So(rds.DeleteMulti([]*Key{mkKey("", "", "", "")}, nil).E rror(), ShouldContainSubstring, "is nil")
117 » » » So(rds.DeleteMulti([]*Key{mkKey("", "", "", "")}, func(e rr error) { 122 » » » So(rds.DeleteMulti([]*Key{mkKey("", "", "", "")}, func(e rr error) error {
118 So(err, ShouldEqual, ErrInvalidKey) 123 So(err, ShouldEqual, ErrInvalidKey)
124 return nil
119 }), ShouldBeNil) 125 }), ShouldBeNil)
120 126
121 hit := false 127 hit := false
122 So(func() { 128 So(func() {
123 » » » » So(rds.DeleteMulti([]*Key{mkKey("s~aid", "ns", " Kind", 1)}, func(error) { 129 » » » » So(rds.DeleteMulti([]*Key{mkKey("s~aid", "ns", " Kind", 1)}, func(error) error {
124 hit = true 130 hit = true
131 return nil
125 }), ShouldBeNil) 132 }), ShouldBeNil)
126 }, ShouldPanic) 133 }, ShouldPanic)
127 So(hit, ShouldBeFalse) 134 So(hit, ShouldBeFalse)
128 }) 135 })
129 136
130 }) 137 })
131 } 138 }
OLDNEW
« no previous file with comments | « impl/prod/raw_datastore.go ('k') | service/datastore/datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698