;; This Source Code Form is subject to the terms of the Mozilla Public ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; Copyright (c) KALEIDOS INC (ns common-tests.files-migrations-test (:require [app.common.data :as d] [app.common.files.migrations :as cfm] [app.common.pprint :as pp] [clojure.test :as t])) (defmethod cfm/migrate-data "test/1" [data _] (update data :sum inc)) (defmethod cfm/migrate-data "test/2" [data _] (update data :sum inc)) (defmethod cfm/migrate-data "test/3" [data _] (update data :sum inc)) (t/deftest generic-migration-subsystem-1 (let [migrations (into (d/ordered-set) ["test/1" "test/2" "test/3"])] (with-redefs [cfm/available-migrations migrations] (let [file {:data {:sum 1} :id 1 :migrations (d/ordered-set "test/1")} file' (cfm/migrate file)] (t/is (= cfm/available-migrations (:migrations file'))) (t/is (= 3 (:sum (:data file'))))))))