| Index: service/datastore/meta/namespaces_test.go
|
| diff --git a/service/datastore/meta/namespaces_test.go b/service/datastore/meta/namespaces_test.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..011ac841f19dfc53c70f09e1a7f9ef862f8d9eca
|
| --- /dev/null
|
| +++ b/service/datastore/meta/namespaces_test.go
|
| @@ -0,0 +1,58 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package meta
|
| +
|
| +import (
|
| + "testing"
|
| +
|
| + "github.com/luci/gae/impl/memory"
|
| + "github.com/luci/gae/service/datastore"
|
| + "github.com/luci/gae/service/info"
|
| + "golang.org/x/net/context"
|
| +
|
| + . "github.com/smartystreets/goconvey/convey"
|
| +)
|
| +
|
| +func TestNamespaces(t *testing.T) {
|
| + t.Parallel()
|
| +
|
| + Convey(`A testing datastore`, t, func() {
|
| + ctx := memory.Use(context.Background())
|
| +
|
| + // Call to add a datastore entry under the supplied namespace.
|
| + addNamespace := func(ns string) {
|
| + c := info.Get(ctx).MustNamespace(ns)
|
| +
|
| + err := datastore.Get(c).Raw().PutMulti(
|
| + []*datastore.Key{
|
| + datastore.Get(c).NewKey("Warblegarble", "", 1, nil),
|
| + },
|
| + []datastore.PropertyMap{
|
| + make(datastore.PropertyMap),
|
| + },
|
| + func(*datastore.Key, error) error { return nil })
|
| + if err != nil {
|
| + panic(err)
|
| + }
|
| +
|
| + datastore.Get(ctx).Testable().CatchupIndexes()
|
| + }
|
| +
|
| + Convey(`A datastore with no namespaces returns {}.`, func() {
|
| + namespaces, err := Namespaces(ctx)
|
| + So(err, ShouldBeNil)
|
| + So(namespaces, ShouldResemble, []string{})
|
| + })
|
| +
|
| + Convey(`A datastore with namespaces {"foo", "bar"} will return {"bar", "foo"}.`, func() {
|
| + addNamespace("foo")
|
| + addNamespace("bar")
|
| +
|
| + namespaces, err := Namespaces(ctx)
|
| + So(err, ShouldBeNil)
|
| + So(namespaces, ShouldResemble, []string{"bar", "foo"})
|
| + })
|
| + })
|
| +}
|
|
|