Skip to content

Commit

Permalink
Playing with put-item cond-expr #106
Browse files Browse the repository at this point in the history
  • Loading branch information
kipz committed Nov 12, 2019
1 parent d118c42 commit a644735
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/taoensso/faraday/tests/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1294,3 +1294,38 @@
(proxy-super listStreams list-streams-request)))]
(doall (far/list-streams (assoc *client-opts* :client client) {:table-name ttable}))
(is (= 1 @calls))))

(deftest attribute-not-exists
;;https://github.com/Taoensso/faraday/issues/106

(far/put-item *client-opts* range-table {:title "Three" :number 33})

(is (thrown?
ConditionalCheckFailedException
(far/put-item *client-opts* range-table {:title "Three" :number 33}
{:cond-expr "attribute_not_exists(#t) AND attribute_not_exists(#n)"
;; note typo in the issue. 'name' should be 'number'
:expr-attr-names {"#n" "name"
"#t" "title"}})))

(is (thrown?
ConditionalCheckFailedException
(far/put-item *client-opts* range-table {:title "Three" :number 33}
{:cond-expr "attribute_not_exists(#t) AND attribute_not_exists(#n)"
;; note typo in the issue: fixed here
:expr-attr-names {"#n" "number"
"#t" "title"}})))

(is (thrown? ConditionalCheckFailedException
(far/put-item *client-opts* range-table {:title "Three" :number 33}
{:cond-expr "attribute_not_exists(#t)"
:expr-attr-names {"#t" "title"}})))

(is (thrown? ConditionalCheckFailedException
(far/put-item *client-opts* range-table {:title "Three" :number 33}
{:cond-expr "attribute_not_exists(#n)"
:expr-attr-names {"#n" "number"}})))

(far/put-item *client-opts* range-table {:title "Three" :number 35}
{:cond-expr "attribute_not_exists(#t)"
:expr-attr-names {"#t" "title"}}))

0 comments on commit a644735

Please sign in to comment.