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

Side by Side Diff: service/datastore/meta/namespaces_test.go

Issue 1917513002: Add meta package to datastore. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Created 4 years, 8 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package meta
6
7 import (
8 "testing"
9
10 "github.com/luci/gae/impl/memory"
11 "github.com/luci/gae/service/datastore"
12 "github.com/luci/gae/service/info"
13 "golang.org/x/net/context"
14
15 . "github.com/smartystreets/goconvey/convey"
16 )
17
18 func TestNamespaces(t *testing.T) {
19 t.Parallel()
20
21 Convey(`A testing datastore`, t, func() {
22 ctx := memory.Use(context.Background())
23
24 // Call to add a datastore entry under the supplied namespace.
25 addNamespace := func(ns string) {
26 c := info.Get(ctx).MustNamespace(ns)
27
28 err := datastore.Get(c).Raw().PutMulti(
29 []*datastore.Key{
30 datastore.Get(c).NewKey("Warblegarble", "", 1, nil),
31 },
32 []datastore.PropertyMap{
33 make(datastore.PropertyMap),
34 },
35 func(*datastore.Key, error) error { return nil } )
36 if err != nil {
37 panic(err)
38 }
39
40 datastore.Get(ctx).Testable().CatchupIndexes()
41 }
42
43 Convey(`A datastore with no namespaces returns {}.`, func() {
44 namespaces, err := Namespaces(ctx)
45 So(err, ShouldBeNil)
46 So(namespaces, ShouldResemble, []string{})
47 })
48
49 Convey(`A datastore with namespaces {"foo", "bar"} will return { "bar", "foo"}.`, func() {
50 addNamespace("foo")
51 addNamespace("bar")
52
53 namespaces, err := Namespaces(ctx)
54 So(err, ShouldBeNil)
55 So(namespaces, ShouldResemble, []string{"bar", "foo"})
56 })
57 })
58 }
OLDNEW
« service/datastore/meta/namespaces.go ('K') | « service/datastore/meta/namespaces.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698