Skip to content

Commit

Permalink
Fix test for snapshot-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
klauswuestefeld committed Nov 7, 2024
1 parent 6473193 commit 84f6e66
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions test/prevayler_clj_aws/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@
(testing "snapshot-v2 is the default snapshot file name"
(let [{{:keys [s3-client s3-bucket]} :aws-opts :as opts} (gen-opts)
_ (prev! opts)]
(is (match? [{:Key "snapshot"} {:Key "snapshot-v2"}] (list-objects s3-client s3-bucket)))))
(is (match? [{:Key "snapshot-v2"}] (list-objects s3-client s3-bucket)))))

(testing "can override snapshot file name"
(let [{{:keys [s3-client s3-bucket]} :aws-opts :as opts} (gen-opts :aws-opts {:snapshot-path "my-path"})
_ (prev! opts)]
(is (match? [{:Key "my-path"} {:Key "my-path-v2"}] (list-objects s3-client s3-bucket)))))
(is (match? [{:Key "my-path-v2"}] (list-objects s3-client s3-bucket)))))

(testing "default initial state is empty map"
(let [prevayler (prev! (gen-opts))]
Expand Down Expand Up @@ -154,15 +154,4 @@
(prevayler/snapshot! prev1)
(prevayler/snapshot! prev1)
(let [prev2 (prev! (assoc opts :business-fn (constantly "rubbish")))]
(is (= ["A" "B" "C" "D"] @prev2)))))

(testing "it generates snapshot v2"
(let [{{:keys [s3-client s3-sdk-cli s3-bucket]} :aws-opts :as opts} (gen-opts)
_ (util/aws-invoke s3-client {:op :PutObject
:request {:Bucket s3-bucket
:Key "snapshot"
:Body (#'core/marshal {:partkey 0
:state :state})}})
prev (prev! opts)] ;; saves snapshot-v2
(is (= :state @prev))
(is (= {:state :state :partkey 1} (#'core/read-object s3-sdk-cli s3-bucket "snapshot-v2" #'core/unmarshal-from-in))))))
(is (= ["A" "B" "C" "D"] @prev2))))))

0 comments on commit 84f6e66

Please sign in to comment.