OLD | NEW |
1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be 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 10 matching lines...) Expand all Loading... |
21 t.Parallel() | 21 t.Parallel() |
22 | 22 |
23 Convey("Test checkFilter", t, func() { | 23 Convey("Test checkFilter", t, func() { |
24 // Note that the way we have this context set up, any calls whic
h aren't | 24 // Note that the way we have this context set up, any calls whic
h aren't |
25 // stopped at the checkFilter will nil-pointer panic. We use thi
s panic | 25 // stopped at the checkFilter will nil-pointer panic. We use thi
s panic |
26 // behavior to indicate that the checkfilter has allowed a call
to pass | 26 // behavior to indicate that the checkfilter has allowed a call
to pass |
27 // through to the implementation in the tests below. In a real a
pplication | 27 // through to the implementation in the tests below. In a real a
pplication |
28 // the panics observed in the tests below would actually be suce
ssful calls | 28 // the panics observed in the tests below would actually be suce
ssful calls |
29 // to the implementation. | 29 // to the implementation. |
30 c := SetRaw(info.Set(context.Background(), fakeInfo{}), fakeRDS{
}) | 30 c := SetRaw(info.Set(context.Background(), fakeInfo{}), fakeRDS{
}) |
31 » » rds := GetRaw(c) // has checkFilter | 31 » » rds := Raw(c) // has checkFilter |
32 So(rds, ShouldNotBeNil) | 32 So(rds, ShouldNotBeNil) |
33 | 33 |
34 Convey("RunInTransaction", func() { | 34 Convey("RunInTransaction", func() { |
35 So(rds.RunInTransaction(nil, nil).Error(), ShouldContain
Substring, "is nil") | 35 So(rds.RunInTransaction(nil, nil).Error(), ShouldContain
Substring, "is nil") |
36 hit := false | 36 hit := false |
37 So(func() { | 37 So(func() { |
38 So(rds.RunInTransaction(func(context.Context) er
ror { | 38 So(rds.RunInTransaction(func(context.Context) er
ror { |
39 hit = true | 39 hit = true |
40 return nil | 40 return nil |
41 }, nil), ShouldBeNil) | 41 }, nil), ShouldBeNil) |
(...skipping 15 matching lines...) Expand all Loading... |
57 }), ShouldBeNil) | 57 }), ShouldBeNil) |
58 }, ShouldPanic) | 58 }, ShouldPanic) |
59 So(hit, ShouldBeFalse) | 59 So(hit, ShouldBeFalse) |
60 }) | 60 }) |
61 | 61 |
62 Convey("GetMulti", func() { | 62 Convey("GetMulti", func() { |
63 So(rds.GetMulti(nil, nil, nil), ShouldBeNil) | 63 So(rds.GetMulti(nil, nil, nil), ShouldBeNil) |
64 So(rds.GetMulti([]*Key{mkKey("", "", "", "")}, nil, nil)
.Error(), ShouldContainSubstring, "is nil") | 64 So(rds.GetMulti([]*Key{mkKey("", "", "", "")}, nil, nil)
.Error(), ShouldContainSubstring, "is nil") |
65 | 65 |
66 // this is in the wrong aid/ns | 66 // this is in the wrong aid/ns |
67 » » » keys := []*Key{MakeKey("wut", "wrong", "Kind", 1)} | 67 » » » keys := []*Key{KeyContext{"wut", "wrong"}.MakeKey("Kind"
, 1)} |
68 So(rds.GetMulti(keys, nil, func(pm PropertyMap, err erro
r) error { | 68 So(rds.GetMulti(keys, nil, func(pm PropertyMap, err erro
r) error { |
69 So(pm, ShouldBeNil) | 69 So(pm, ShouldBeNil) |
70 So(err, ShouldEqual, ErrInvalidKey) | 70 So(err, ShouldEqual, ErrInvalidKey) |
71 return nil | 71 return nil |
72 }), ShouldBeNil) | 72 }), ShouldBeNil) |
73 | 73 |
74 keys[0] = mkKey("Kind", 1) | 74 keys[0] = mkKey("Kind", 1) |
75 hit := false | 75 hit := false |
76 So(func() { | 76 So(func() { |
77 So(rds.GetMulti(keys, nil, func(pm PropertyMap,
err error) error { | 77 So(rds.GetMulti(keys, nil, func(pm PropertyMap,
err error) error { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 So(rds.DeleteMulti([]*Key{mkKey("s~aid", "ns", "
Kind", 1)}, func(error) error { | 130 So(rds.DeleteMulti([]*Key{mkKey("s~aid", "ns", "
Kind", 1)}, func(error) error { |
131 hit = true | 131 hit = true |
132 return nil | 132 return nil |
133 }), ShouldBeNil) | 133 }), ShouldBeNil) |
134 }, ShouldPanic) | 134 }, ShouldPanic) |
135 So(hit, ShouldBeFalse) | 135 So(hit, ShouldBeFalse) |
136 }) | 136 }) |
137 | 137 |
138 }) | 138 }) |
139 } | 139 } |
OLD | NEW |