| 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 package memory | 5 package memory |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "testing" | 9 "testing" |
| 10 | 10 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 {"silly inequality (=> v <=)", | 111 {"silly inequality (=> v <=)", |
| 112 nq().Gte("bob", 10).Lte("bob", 10), | 112 nq().Gte("bob", 10).Lte("bob", 10), |
| 113 nil, nil}, | 113 nil, nil}, |
| 114 | 114 |
| 115 {"cursors get smooshed into the inquality range", | 115 {"cursors get smooshed into the inquality range", |
| 116 (nq().Gt("Foo", 3).Lt("Foo", 10). | 116 (nq().Gt("Foo", 3).Lt("Foo", 10). |
| 117 Start(curs("Foo", 2, "__key__", key("Something", 1))). | 117 Start(curs("Foo", 2, "__key__", key("Something", 1))). |
| 118 End(curs("Foo", 20, "__key__", key("Something", 20)))), | 118 End(curs("Foo", 20, "__key__", key("Something", 20)))), |
| 119 nil, | 119 nil, |
| 120 &reducedQuery{ | 120 &reducedQuery{ |
| 121 » » » dstore.KeyContext{"dev~app", "ns"}, | 121 » » » dstore.MkKeyContext("dev~app", "ns"), |
| 122 "Foo", map[string]stringset.Set{}, []dstore.IndexColumn{ | 122 "Foo", map[string]stringset.Set{}, []dstore.IndexColumn{ |
| 123 {Property: "Foo"}, | 123 {Property: "Foo"}, |
| 124 {Property: "__key__"}, | 124 {Property: "__key__"}, |
| 125 }, | 125 }, |
| 126 increment(serialize.ToBytes(dstore.MkProperty(3))), | 126 increment(serialize.ToBytes(dstore.MkProperty(3))), |
| 127 serialize.ToBytes(dstore.MkProperty(10)), | 127 serialize.ToBytes(dstore.MkProperty(10)), |
| 128 2, | 128 2, |
| 129 }}, | 129 }}, |
| 130 | 130 |
| 131 {"cursors could cause the whole query to be useless", | 131 {"cursors could cause the whole query to be useless", |
| 132 (nq().Gt("Foo", 3).Lt("Foo", 10). | 132 (nq().Gt("Foo", 3).Lt("Foo", 10). |
| 133 Start(curs("Foo", 200, "__key__", key("Something", 1))). | 133 Start(curs("Foo", 200, "__key__", key("Something", 1))). |
| 134 End(curs("Foo", 1, "__key__", key("Something", 20)))), | 134 End(curs("Foo", 1, "__key__", key("Something", 20)))), |
| 135 dstore.ErrNullQuery, | 135 dstore.ErrNullQuery, |
| 136 nil}, | 136 nil}, |
| 137 } | 137 } |
| 138 | 138 |
| 139 func TestQueries(t *testing.T) { | 139 func TestQueries(t *testing.T) { |
| 140 t.Parallel() | 140 t.Parallel() |
| 141 | 141 |
| 142 Convey("queries have tons of condition checking", t, func() { | 142 Convey("queries have tons of condition checking", t, func() { |
| 143 » » kc := dstore.KeyContext{"dev~app", "ns"} | 143 » » kc := dstore.MkKeyContext("dev~app", "ns") |
| 144 | 144 |
| 145 Convey("non-ancestor queries in a transaction", func() { | 145 Convey("non-ancestor queries in a transaction", func() { |
| 146 fq, err := nq().Finalize() | 146 fq, err := nq().Finalize() |
| 147 So(err, ShouldErrLike, nil) | 147 So(err, ShouldErrLike, nil) |
| 148 _, err = reduce(fq, kc, true) | 148 _, err = reduce(fq, kc, true) |
| 149 So(err, ShouldErrLike, "must include an Ancestor") | 149 So(err, ShouldErrLike, "must include an Ancestor") |
| 150 }) | 150 }) |
| 151 | 151 |
| 152 Convey("absurd numbers of filters are prohibited", func() { | 152 Convey("absurd numbers of filters are prohibited", func() { |
| 153 q := nq().Ancestor(key("thing", "wat")) | 153 q := nq().Ancestor(key("thing", "wat")) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 174 So(err, ShouldErrLike, tc.err) | 174 So(err, ShouldErrLike, tc.err) |
| 175 | 175 |
| 176 if tc.equivalentQuery != nil { | 176 if tc.equivalentQuery != nil { |
| 177 So(rq, ShouldResemble, tc.equiva
lentQuery) | 177 So(rq, ShouldResemble, tc.equiva
lentQuery) |
| 178 } | 178 } |
| 179 }) | 179 }) |
| 180 } | 180 } |
| 181 }) | 181 }) |
| 182 }) | 182 }) |
| 183 } | 183 } |
| OLD | NEW |