From 017523ab8bbd4130b905a93de4513823f8dcb995 Mon Sep 17 00:00:00 2001 From: Oleksandr Petrov Date: Mon, 19 Dec 2011 23:07:53 +0100 Subject: [PATCH] Adding versioning test and test with procreated index. --- .gitignore | 1 + src/elastisch/utils.clj | 2 +- test/elastisch/test/core.clj | 26 ++++++++++++++++++++++++++ test/elastisch/test/fixtures.clj | 12 ++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 488c16c1..02a8dd30 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ pom.xml /classes/ .lein-failures .lein-deps-sum +*~ \ No newline at end of file diff --git a/src/elastisch/utils.clj b/src/elastisch/utils.clj index 2d126546..d11bca6b 100644 --- a/src/elastisch/utils.clj +++ b/src/elastisch/utils.clj @@ -14,7 +14,7 @@ (defn ok? [response] - (:ok response)) + (= true (:ok response))) (defn acknowledged? [response] diff --git a/test/elastisch/test/core.clj b/test/elastisch/test/core.clj index e3f91b4c..fdbfe2f0 100644 --- a/test/elastisch/test/core.clj +++ b/test/elastisch/test/core.clj @@ -26,6 +26,32 @@ id :_id true :exists))) +(deftest put-record-precreated-index-test + (let [index "people" + type "person" + id "1" + _ (index/create index :mappings fixtures/people-mapping) + document fixtures/person-jack + response (put-record index type id document) + get-result (get-record index type id)] + (is (= true (utils/ok? response))) + (are [expected actual] (= expected (actual get-result)) + document :_source + index :_index + type :_type + id :_id + true :exists))) + +(deftest put-record-versioned-test + (let [index "people" + type "person" + id "1" + document fixtures/person-joe + response_v1 (put-record index type id fixtures/person-jack) + response_middle (put-record index type id fixtures/person-mary) + response (put-record index type id fixtures/person-joe :version 1)] + (is (= false (utils/ok? response))))) + ;; deftest optional-type ;; deftest fields ;; deftest routing diff --git a/test/elastisch/test/fixtures.clj b/test/elastisch/test/fixtures.clj index c73be6b0..144d9313 100644 --- a/test/elastisch/test/fixtures.clj +++ b/test/elastisch/test/fixtures.clj @@ -13,6 +13,18 @@ :title "Sales Manager" :biography "Tries to avoid eating fat, being good to other people and does sports every now and then" }) +(def person-joe { + :first-name "Joe" + :last-name "Mahjo" + :title "Trader" + :biography "Quite a nice guy" }) + +(def person-mary { + :first-name "Mary" + :last-name "Lindey" + :title "Copywriter" + :biography "Writes copy and copies writes" }) + (def people-mapping { :person { :properties {