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

Unified Diff: service/datastore/datastore_test.go

Issue 1523943002: Fix nil-deref panic from Put. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « service/datastore/datastore.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/datastore_test.go
diff --git a/service/datastore/datastore_test.go b/service/datastore/datastore_test.go
index 2e3b7fa1ba5e922558f5ff0b52ccfef76a18b38d..8c536bd9c3a561a30b9f6d5e66e92b122f75b7e4 100644
--- a/service/datastore/datastore_test.go
+++ b/service/datastore/datastore_test.go
@@ -414,6 +414,16 @@ func TestPut(t *testing.T) {
s := MGSWithNoKind{}
So(ds.Put(&s), ShouldErrLike, "unable to extract $kind")
})
+
+ Convey("struct with invalid but non-nil key is an error", func() {
+ type BadParent struct {
+ ID int64 `gae:"$id"`
+ Parent *Key `gae:"$parent"`
+ }
+ // having an Incomplete parent makes an invalid key
+ bp := &BadParent{ID: 1, Parent: ds.MakeKey("Something", 0)}
+ So(ds.Put(bp), ShouldErrLike, ErrInvalidKey)
+ })
})
Convey("ok", func() {
« no previous file with comments | « service/datastore/datastore.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698