зеркало из https://github.com/golang/appengine.git
Make a Datastore key's namespace available to the app.
Change-Id: Icaad90e0958a516af684a522749df2299c1ed585
This commit is contained in:
Родитель
f70a51906c
Коммит
a5bf4a208e
|
@ -56,6 +56,11 @@ func (k *Key) AppID() string {
|
||||||
return k.appID
|
return k.appID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Namespace returns the key's namespace.
|
||||||
|
func (k *Key) Namespace() string {
|
||||||
|
return k.namespace
|
||||||
|
}
|
||||||
|
|
||||||
// Incomplete returns whether the key does not refer to a stored entity.
|
// Incomplete returns whether the key does not refer to a stored entity.
|
||||||
// In particular, whether the key has a zero StringID and a zero IntID.
|
// In particular, whether the key has a zero StringID and a zero IntID.
|
||||||
func (k *Key) Incomplete() bool {
|
func (k *Key) Incomplete() bool {
|
||||||
|
|
|
@ -200,3 +200,15 @@ func TestIncompleteKeyWithParent(t *testing.T) {
|
||||||
t.Errorf("robert is invalid: %v", robert)
|
t.Errorf("robert is invalid: %v", robert)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNamespace(t *testing.T) {
|
||||||
|
key := &Key{
|
||||||
|
kind: "Person",
|
||||||
|
intID: 1,
|
||||||
|
appID: "s~some-app",
|
||||||
|
namespace: "mynamespace",
|
||||||
|
}
|
||||||
|
if g, w := key.Namespace(), "mynamespace"; g != w {
|
||||||
|
t.Errorf("key.Namespace() = %q, want %q", g, w)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче