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

Unified 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 side-by-side diff with in-line comments
Download patch
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"})
+ })
+ })
+}
« 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