OLD | NEW |
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 "testing" | 9 "testing" |
10 "time" | 10 "time" |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 So(vals[0]["Value"][0].Value(), ShouldEqual, 20) | 632 So(vals[0]["Value"][0].Value(), ShouldEqual, 20) |
633 So(vals[1]["Value"][0].Value(), ShouldEqual, 30) | 633 So(vals[1]["Value"][0].Value(), ShouldEqual, 30) |
634 }) | 634 }) |
635 } | 635 } |
636 | 636 |
637 func TestAddIndexes(t *testing.T) { | 637 func TestAddIndexes(t *testing.T) { |
638 t.Parallel() | 638 t.Parallel() |
639 | 639 |
640 Convey("Test Testable.AddIndexes", t, func() { | 640 Convey("Test Testable.AddIndexes", t, func() { |
641 ctx := UseWithAppID(context.Background(), "aid") | 641 ctx := UseWithAppID(context.Background(), "aid") |
642 » » namespaces := []string{"", "good", "news", "everyone"} | 642 » » namespaces := []string{"good", "news", "everyone"} |
643 | 643 |
644 Convey("After adding datastore entries, can query against indexe
s in various namespaces", func() { | 644 Convey("After adding datastore entries, can query against indexe
s in various namespaces", func() { |
645 foos := []*Foo{ | 645 foos := []*Foo{ |
646 {ID: 1, Val: 1, Name: "foo"}, | 646 {ID: 1, Val: 1, Name: "foo"}, |
647 {ID: 2, Val: 2, Name: "bar"}, | 647 {ID: 2, Val: 2, Name: "bar"}, |
648 {ID: 3, Val: 2, Name: "baz"}, | 648 {ID: 3, Val: 2, Name: "baz"}, |
649 } | 649 } |
650 for _, ns := range namespaces { | 650 for _, ns := range namespaces { |
651 So(dsS.Get(infoS.Get(ctx).MustNamespace(ns)).Put
Multi(foos), ShouldBeNil) | 651 So(dsS.Get(infoS.Get(ctx).MustNamespace(ns)).Put
Multi(foos), ShouldBeNil) |
652 } | 652 } |
(...skipping 14 matching lines...) Expand all Loading... |
667 }, | 667 }, |
668 }) | 668 }) |
669 dsS.Get(ctx).Testable().CatchupIndexes() | 669 dsS.Get(ctx).Testable().CatchupIndexes() |
670 | 670 |
671 for _, ns := range namespaces { | 671 for _, ns := range namespaces { |
672 results = nil | 672 results = nil |
673 So(dsS.Get(infoS.Get(ctx).MustNamespace(ns)).Get
All(q, &results), ShouldBeNil) | 673 So(dsS.Get(infoS.Get(ctx).MustNamespace(ns)).Get
All(q, &results), ShouldBeNil) |
674 So(len(results), ShouldEqual, 2) | 674 So(len(results), ShouldEqual, 2) |
675 } | 675 } |
676 | 676 |
677 » » » // Add "foos" to a new namesapce, then confirm that it g
ets indexed. | 677 » » » // Add "foos" to a new namespace, then confirm that it g
ets indexed. |
678 So(dsS.Get(infoS.Get(ctx).MustNamespace("qux")).PutMulti
(foos), ShouldBeNil) | 678 So(dsS.Get(infoS.Get(ctx).MustNamespace("qux")).PutMulti
(foos), ShouldBeNil) |
679 dsS.Get(ctx).Testable().CatchupIndexes() | 679 dsS.Get(ctx).Testable().CatchupIndexes() |
680 | 680 |
681 results = nil | 681 results = nil |
682 So(dsS.Get(infoS.Get(ctx).MustNamespace("qux")).GetAll(q
, &results), ShouldBeNil) | 682 So(dsS.Get(infoS.Get(ctx).MustNamespace("qux")).GetAll(q
, &results), ShouldBeNil) |
683 So(len(results), ShouldEqual, 2) | 683 So(len(results), ShouldEqual, 2) |
684 }) | 684 }) |
685 }) | 685 }) |
686 } | 686 } |
OLD | NEW |