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

Side by Side Diff: impl/prod/everything_test.go

Issue 2986533002: [datastore] Fix querying with []byte. (Closed)
Patch Set: add crappy test Created 3 years, 5 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
« no previous file with comments | « no previous file | impl/prod/raw_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 LUCI Authors. 1 // Copyright 2015 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 Convey("Can query", func() { 162 Convey("Can query", func() {
163 q := ds.NewQuery("TestStruct") 163 q := ds.NewQuery("TestStruct")
164 ds.Run(ctx, q, func(ts *TestStruct) { 164 ds.Run(ctx, q, func(ts *TestStruct) {
165 So(*ts, ShouldResemble, orig) 165 So(*ts, ShouldResemble, orig)
166 }) 166 })
167 count, err := ds.Count(ctx, q) 167 count, err := ds.Count(ctx, q)
168 So(err, ShouldBeNil) 168 So(err, ShouldBeNil)
169 So(count, ShouldEqual, 1) 169 So(count, ShouldEqual, 1)
170 }) 170 })
171 171
172 Convey("Can query for bytes", func() {
173 q := ds.NewQuery("TestStruct").Eq("ValueBS", []b yte("allo"))
174 ds.Run(ctx, q, func(ts *TestStruct) {
175 So(*ts, ShouldResemble, orig)
176 })
177 count, err := ds.Count(ctx, q)
178 So(err, ShouldBeNil)
179 So(count, ShouldEqual, 1)
180 })
181
172 Convey("Can project", func() { 182 Convey("Can project", func() {
173 q := ds.NewQuery("TestStruct").Project("ValueS") 183 q := ds.NewQuery("TestStruct").Project("ValueS")
174 rslts := []ds.PropertyMap{} 184 rslts := []ds.PropertyMap{}
175 So(ds.GetAll(ctx, q, &rslts), ShouldBeNil) 185 So(ds.GetAll(ctx, q, &rslts), ShouldBeNil)
176 So(rslts, ShouldResemble, []ds.PropertyMap{ 186 So(rslts, ShouldResemble, []ds.PropertyMap{
177 { 187 {
178 "$key": mpNI(ds.KeyForObj(ctx, &orig)), 188 "$key": mpNI(ds.KeyForObj(ctx, &orig)),
179 "ValueS": mp("hello"), 189 "ValueS": mp("hello"),
180 }, 190 },
181 { 191 {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 default: 337 default:
328 return err 338 return err
329 } 339 }
330 }, &ds.TransactionOptions{Attempts: 9999999}) 340 }, &ds.TransactionOptions{Attempts: 9999999})
331 if err != nil { 341 if err != nil {
332 b.Fatalf("failed to run transaction: %v", err) 342 b.Fatalf("failed to run transaction: %v", err)
333 } 343 }
334 } 344 }
335 }) 345 })
336 } 346 }
OLDNEW
« no previous file with comments | « no previous file | impl/prod/raw_datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698