Skip to content
Browse files

Fix ds/get and test ds/delete for deleting multiple.

  • Loading branch information...
1 parent 7fcd612 commit 297fa40a129479101d5f4524c0ea6a252a0d2e79 @duelinmarkers committed
Showing with 13 additions and 1 deletion.
  1. +1 −1 src/appengine_clj/datastore.clj
  2. +12 −0 test/appengine_clj/datastore_test.clj
View
2 src/appengine_clj/datastore.clj
@@ -16,7 +16,7 @@
(defn get
"Retrieves the identified entity or raises EntityNotFoundException."
[#^Key key]
- (.get (DatastoreServiceFactory/getDatastoreService) key))
+ (entity-to-map (.get (DatastoreServiceFactory/getDatastoreService) key)))
(defn find-all
"Executes the given com.google.appengine.api.datastore.Query
View
12 test/appengine_clj/datastore_test.clj
@@ -44,8 +44,20 @@
(is (= (parent :key) (.getParent (child :key))))
(is (= [child] (ds/find-all (doto (Query. "Child" (parent :key))))))))
+(dstest get-given-a-key-returns-a-mapified-entity
+ (let [key (:key (ds/create {:kind "Person" :name "cliff"}))]
+ (is (= "cliff" ((ds/get key) :name)))))
+
(dstest delete-by-key
(let [key (:key (ds/create {:kind "MyKind"}))]
(ds/delete key)
(is (thrown? EntityNotFoundException (ds/get key)))))
+(dstest delete-by-multiple-keys
+ (let [key1 (:key (ds/create {:kind "MyKind"}))
+ key2 (:key (ds/create {:kind "MyKind"}))]
+ (ds/delete key1 key2)
+ (are (thrown? EntityNotFoundException (ds/get _1))
+ key1
+ key2)))
+

0 comments on commit 297fa40

Please sign in to comment.
Something went wrong with that request. Please try again.