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

Side by Side Diff: go/src/infra/gae/libs/wrapper/memory/datastore_test.go

Issue 1162813002: Fix overflow on 32bit which causes tests to fail on 32bit. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | 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 package memory 5 package memory
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "infra/gae/libs/meta" 9 "infra/gae/libs/meta"
10 "infra/gae/libs/wrapper" 10 "infra/gae/libs/wrapper"
11 "math"
12 "testing" 11 "testing"
13 12
14 . "github.com/smartystreets/goconvey/convey" 13 . "github.com/smartystreets/goconvey/convey"
15 "golang.org/x/net/context" 14 "golang.org/x/net/context"
16 15
17 "appengine/datastore" 16 "appengine/datastore"
18 ) 17 )
19 18
20 func TestDatastoreKinder(t *testing.T) { 19 func TestDatastoreKinder(t *testing.T) {
21 t.Parallel() 20 t.Parallel()
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 So(ds.Get(f), ShouldBeNil) 516 So(ds.Get(f), ShouldBeNil)
518 So(f.Val, ShouldEqual, 10) 517 So(f.Val, ShouldEqual, 10)
519 }) 518 })
520 }) 519 })
521 }) 520 })
522 }) 521 })
523 522
524 }) 523 })
525 } 524 }
526 525
526 const MaxUint = ^uint(0)
527 const MaxInt = int(MaxUint >> 1)
528
527 func TestDatastoreQueryer(t *testing.T) { 529 func TestDatastoreQueryer(t *testing.T) {
528 Convey("Datastore Query suport", t, func() { 530 Convey("Datastore Query suport", t, func() {
529 c := Use(context.Background()) 531 c := Use(context.Background())
530 ds := wrapper.GetDS(c) 532 ds := wrapper.GetDS(c)
531 So(ds, ShouldNotBeNil) 533 So(ds, ShouldNotBeNil)
532 534
533 Convey("can create good queries", func() { 535 Convey("can create good queries", func() {
534 q := ds.NewQuery("Foo").KeysOnly().Limit(10).Offset(39) 536 q := ds.NewQuery("Foo").KeysOnly().Limit(10).Offset(39)
535 q = q.Start(queryCursor("kosmik")).End(queryCursor("krab s")) 537 q = q.Start(queryCursor("kosmik")).End(queryCursor("krab s"))
536 So(q, ShouldNotBeNil) 538 So(q, ShouldNotBeNil)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 }) 589 })
588 Convey("bad order", func() { 590 Convey("bad order", func() {
589 q := q.Order("+Bob") 591 q := q.Order("+Bob")
590 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "invalid order") 592 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "invalid order")
591 }) 593 })
592 Convey("empty", func() { 594 Convey("empty", func() {
593 q := q.Order("") 595 q := q.Order("")
594 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "empty order") 596 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "empty order")
595 }) 597 })
596 Convey("OOB limit", func() { 598 Convey("OOB limit", func() {
597 » » » » q := q.Limit(math.MaxInt64) 599 » » » » q := q.Limit(MaxInt)
598 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "query limit overflow") 600 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "query limit overflow")
599 }) 601 })
600 Convey("underflow offset", func() { 602 Convey("underflow offset", func() {
601 q := q.Offset(-29) 603 q := q.Offset(-29)
602 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "negative query offset") 604 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "negative query offset")
603 }) 605 })
604 Convey("OOB offset", func() { 606 Convey("OOB offset", func() {
605 » » » » q := q.Offset(math.MaxInt64) 607 » » » » q := q.Offset(MaxInt)
606 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "query offset overflow") 608 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "query offset overflow")
607 }) 609 })
608 Convey("Bad cursors", func() { 610 Convey("Bad cursors", func() {
609 q := q.Start(queryCursor("")).End(queryCursor("" )) 611 q := q.Start(queryCursor("")).End(queryCursor("" ))
610 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "invalid cursor") 612 So(q.(*queryImpl).err.Error(), ShouldContainSubs tring, "invalid cursor")
611 }) 613 })
612 Convey("Bad ancestors", func() { 614 Convey("Bad ancestors", func() {
613 q := q.Ancestor(ds.NewKey("Goop", "wat", 10, nil )) 615 q := q.Ancestor(ds.NewKey("Goop", "wat", 10, nil ))
614 So(q, ShouldNotBeNil) 616 So(q, ShouldNotBeNil)
615 qi := q.(*queryImpl).checkCorrectness("", false) 617 qi := q.(*queryImpl).checkCorrectness("", false)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 }) 665 })
664 Convey("kindless with decending-__key__ orders", func() { 666 Convey("kindless with decending-__key__ orders", func() {
665 q := ds.NewQuery("").Order("-__key__") 667 q := ds.NewQuery("").Order("-__key__")
666 qi := q.(*queryImpl).checkCorrectness("", false) 668 qi := q.(*queryImpl).checkCorrectness("", false)
667 So(qi.err.Error(), ShouldContainSubstring, "kind is required for all orders") 669 So(qi.err.Error(), ShouldContainSubstring, "kind is required for all orders")
668 }) 670 })
669 }) 671 })
670 672
671 }) 673 })
672 } 674 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698