Skip to content

Commit

Permalink
Adding versioning test and test with procreated index.
Browse files Browse the repository at this point in the history
  • Loading branch information
ifesdjeen committed Dec 19, 2011
1 parent 9545a4a commit 017523a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,3 +4,4 @@ pom.xml
/classes/
.lein-failures
.lein-deps-sum
*~
2 changes: 1 addition & 1 deletion src/elastisch/utils.clj
Expand Up @@ -14,7 +14,7 @@

(defn ok?
[response]
(:ok response))
(= true (:ok response)))

(defn acknowledged?
[response]
Expand Down
26 changes: 26 additions & 0 deletions test/elastisch/test/core.clj
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/elastisch/test/fixtures.clj
Expand Up @@ -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 {
Expand Down

0 comments on commit 017523a

Please sign in to comment.