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

Side by Side Diff: filter/txnBuf/txnbuf_test.go

Issue 1516173002: Fix error message from KeyForObj when passing an invalid struct. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: remove accidental extra test 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
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 txnBuf 5 package txnBuf
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "math/rand" 10 "math/rand"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 {2, 4}, 488 {2, 4},
489 {3, 4}, 489 {3, 4},
490 {2, 5}, 490 {2, 5},
491 {3, 5}, 491 {3, 5},
492 {4, 5}, 492 {4, 5},
493 {2, 6}, 493 {2, 6},
494 {3, 6}, 494 {3, 6},
495 } 495 }
496 496
497 for i, pm := range vals { 497 for i, pm := range vals {
498 » » » » » » So(pm.GetMetaDefault("key", nil) , ShouldResemble, ds.MakeKey("Parent", 1, "Foo", expect[i].id)) 498 » » » » » » So(datastore.GetMetaDefault(pm, "key", nil), ShouldResemble,
499 » » » » » » » ds.MakeKey("Parent", 1, "Foo", expect[i].id))
499 So(pm["Value"][0].Value(), Shoul dEqual, expect[i].val) 500 So(pm["Value"][0].Value(), Shoul dEqual, expect[i].val)
500 } 501 }
501 502
502 // should remove 4 entries, but there ar e plenty more to fill 503 // should remove 4 entries, but there ar e plenty more to fill
503 So(ds.Delete(ds.MakeKey("Parent", 1, "Fo o", 2)), ShouldBeNil) 504 So(ds.Delete(ds.MakeKey("Parent", 1, "Fo o", 2)), ShouldBeNil)
504 505
505 vals = []datastore.PropertyMap{} 506 vals = []datastore.PropertyMap{}
506 So(ds.GetAll(q, &vals), ShouldBeNil) 507 So(ds.GetAll(q, &vals), ShouldBeNil)
507 So(len(vals), ShouldEqual, 10) 508 So(len(vals), ShouldEqual, 10)
508 509
509 expect = []struct { 510 expect = []struct {
510 id int64 511 id int64
511 val int64 512 val int64
512 }{ 513 }{
513 // note (3, 3) and (4, 3) are co rrectly missing because deleting 514 // note (3, 3) and (4, 3) are co rrectly missing because deleting
514 // 2 removed two entries which a re hidden by the Offset(4). 515 // 2 removed two entries which a re hidden by the Offset(4).
515 {3, 4}, 516 {3, 4},
516 {3, 5}, 517 {3, 5},
517 {4, 5}, 518 {4, 5},
518 {3, 6}, 519 {3, 6},
519 {3, 7}, 520 {3, 7},
520 {4, 7}, 521 {4, 7},
521 {3, 8}, 522 {3, 8},
522 {3, 9}, 523 {3, 9},
523 {4, 9}, 524 {4, 9},
524 {4, 11}, 525 {4, 11},
525 } 526 }
526 527
527 for i, pm := range vals { 528 for i, pm := range vals {
528 » » » » » » So(pm.GetMetaDefault("key", nil) , ShouldResemble, ds.MakeKey("Parent", 1, "Foo", expect[i].id)) 529 » » » » » » So(datastore.GetMetaDefault(pm, "key", nil), ShouldResemble,
530 » » » » » » » ds.MakeKey("Parent", 1, "Foo", expect[i].id))
529 So(pm["Value"][0].Value(), Shoul dEqual, expect[i].val) 531 So(pm["Value"][0].Value(), Shoul dEqual, expect[i].val)
530 } 532 }
531 533
532 So(ds.Put(&Foo{ID: 1, Parent: root, Valu e: []int64{3, 9}}), ShouldBeNil) 534 So(ds.Put(&Foo{ID: 1, Parent: root, Valu e: []int64{3, 9}}), ShouldBeNil)
533 535
534 vals = []datastore.PropertyMap{} 536 vals = []datastore.PropertyMap{}
535 So(ds.GetAll(q, &vals), ShouldBeNil) 537 So(ds.GetAll(q, &vals), ShouldBeNil)
536 So(len(vals), ShouldEqual, 10) 538 So(len(vals), ShouldEqual, 10)
537 539
538 expect = []struct { 540 expect = []struct {
539 id int64 541 id int64
540 val int64 542 val int64
541 }{ 543 }{
542 // 'invisible' {1, 3} entry bump s the {4, 3} into view. 544 // 'invisible' {1, 3} entry bump s the {4, 3} into view.
543 {4, 3}, 545 {4, 3},
544 {3, 4}, 546 {3, 4},
545 {3, 5}, 547 {3, 5},
546 {4, 5}, 548 {4, 5},
547 {3, 6}, 549 {3, 6},
548 {3, 7}, 550 {3, 7},
549 {4, 7}, 551 {4, 7},
550 {3, 8}, 552 {3, 8},
551 {1, 9}, 553 {1, 9},
552 {3, 9}, 554 {3, 9},
553 {4, 9}, 555 {4, 9},
554 } 556 }
555 557
556 for i, pm := range vals { 558 for i, pm := range vals {
557 » » » » » » So(pm.GetMetaDefault("key", nil) , ShouldResemble, ds.MakeKey("Parent", 1, "Foo", expect[i].id)) 559 » » » » » » So(datastore.GetMetaDefault(pm, "key", nil), ShouldResemble,
560 » » » » » » » ds.MakeKey("Parent", 1, "Foo", expect[i].id))
558 So(pm["Value"][0].Value(), Shoul dEqual, expect[i].val) 561 So(pm["Value"][0].Value(), Shoul dEqual, expect[i].val)
559 } 562 }
560 563
561 return nil 564 return nil
562 }, nil), ShouldBeNil) 565 }, nil), ShouldBeNil)
563 566
564 }) 567 })
565 568
566 Convey("project+distinct", func() { 569 Convey("project+distinct", func() {
567 _, _, ds := mkds([]*Foo{ 570 _, _, ds := mkds([]*Foo{
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 {3, 8}, 605 {3, 8},
603 {3, 9}, 606 {3, 9},
604 {4, 11}, 607 {4, 11},
605 {5, 70}, 608 {5, 70},
606 {4, 100}, 609 {4, 100},
607 {5, 101}, 610 {5, 101},
608 } 611 }
609 612
610 for i, pm := range vals { 613 for i, pm := range vals {
611 So(pm["Value"][0].Value(), Shoul dEqual, expect[i].val) 614 So(pm["Value"][0].Value(), Shoul dEqual, expect[i].val)
612 » » » » » » So(pm.GetMetaDefault("key", nil) , ShouldResemble, ds.MakeKey("Parent", 1, "Foo", expect[i].id)) 615 » » » » » » So(datastore.GetMetaDefault(pm, "key", nil), ShouldResemble,
616 » » » » » » » ds.MakeKey("Parent", 1, "Foo", expect[i].id))
613 } 617 }
614 618
615 return nil 619 return nil
616 }, nil), ShouldBeNil) 620 }, nil), ShouldBeNil)
617 }) 621 })
618 622
619 Convey("overwrite", func() { 623 Convey("overwrite", func() {
620 data := []*Foo{ 624 data := []*Foo{
621 {ID: 2, Parent: root, Value: []int64{1, 2, 3, 4, 5, 6, 7}}, 625 {ID: 2, Parent: root, Value: []int64{1, 2, 3, 4, 5, 6, 7}},
622 {ID: 3, Parent: root, Value: []int64{3, 4, 5, 6, 7, 8, 9}}, 626 {ID: 3, Parent: root, Value: []int64{3, 4, 5, 6, 7, 8, 9}},
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 {5, 101}, 713 {5, 101},
710 {5, 70}, 714 {5, 70},
711 {3, 9}, 715 {3, 9},
712 {3, 8}, 716 {3, 8},
713 {4, 100}, 717 {4, 100},
714 {4, 11}, 718 {4, 11},
715 } 719 }
716 720
717 for i, pm := range vals { 721 for i, pm := range vals {
718 So(pm["Value"][0].Value(), Shoul dEqual, expect[i].val) 722 So(pm["Value"][0].Value(), Shoul dEqual, expect[i].val)
719 » » » » » » So(pm.GetMetaDefault("key", nil) , ShouldResemble, ds.MakeKey("Parent", 1, "Foo", expect[i].id)) 723 » » » » » » So(datastore.GetMetaDefault(pm, "key", nil), ShouldResemble,
724 » » » » » » » ds.MakeKey("Parent", 1, "Foo", expect[i].id))
720 } 725 }
721 726
722 return nil 727 return nil
723 }, nil), ShouldBeNil) 728 }, nil), ShouldBeNil)
724 }) 729 })
725 730
726 Convey("buffered entity sorts before ineq, but after fir st parent entity", func() { 731 Convey("buffered entity sorts before ineq, but after fir st parent entity", func() {
727 // If we got this wrong, we'd see Foo,3 come bef ore Foo,2. This might 732 // If we got this wrong, we'd see Foo,3 come bef ore Foo,2. This might
728 // happen because we calculate the comparison st ring for each entity 733 // happen because we calculate the comparison st ring for each entity
729 // based on the whole entity, but we forgot to l imit the comparison 734 // based on the whole entity, but we forgot to l imit the comparison
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 So(val[len(val)-1].Value(), ShouldResemb le, "wat") 871 So(val[len(val)-1].Value(), ShouldResemb le, "wat")
867 return true 872 return true
868 }), ShouldBeNil) 873 }), ShouldBeNil)
869 }) 874 })
870 875
871 }) 876 })
872 877
873 }) 878 })
874 879
875 } 880 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698