Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
Implement QueryAllBuildNumbersSource #131
Browse files Browse the repository at this point in the history
  • Loading branch information
flosell committed Oct 22, 2016
1 parent bb191b0 commit a11abd4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/clj/lambdacd/internal/default_pipeline_state.clj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@
(get @state-atom build-number))
protocols/NextBuildNumberSource
(next-build-number [self]
(inc (most-recent-build-number-in-state @state-atom))))
(inc (most-recent-build-number-in-state @state-atom)))
protocols/QueryAllBuildNumbersSource
(all-build-numbers [self]
(-> @state-atom
(keys)
(sort))))

(defn new-default-pipeline-state [config & {:keys [initial-state-for-testing]}]
(let [home-dir (:home-dir config)
Expand Down
11 changes: 9 additions & 2 deletions test/clj/lambdacd/internal/default_pipeline_state_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@

(deftest next-build-number-test
(testing "that the next buildnumber is the highest build-number currently in the pipeline-state"
(is (= 1 (next-build-number (new-default-pipeline-state {:home-dir (utils/create-temp-dir)}))))
(is (= 5 (next-build-number (new-default-pipeline-state {:home-dir (utils/create-temp-dir)} :initial-state-for-testing { 3 {} 4 {} 1 {}}))))))
(is (= 1 (protocols/next-build-number (new-default-pipeline-state {:home-dir (utils/create-temp-dir)}))))
(is (= 5 (protocols/next-build-number (new-default-pipeline-state {:home-dir (utils/create-temp-dir)}
:initial-state-for-testing {3 {} 4 {} 1 {}}))))))

(deftest all-build-numbers-test
(testing "that we can get a list of all build numbers"
(is (= [] (protocols/all-build-numbers (new-default-pipeline-state {:home-dir (utils/create-temp-dir)}))))
(is (= [1 3 4] (protocols/all-build-numbers (new-default-pipeline-state {:home-dir (utils/create-temp-dir)}
:initial-state-for-testing (sorted-map-by > 3 {} 4 {} 1 {})))))))

(deftest pipeline-structure-state-test
(testing "that we can consume and retrieve pipeline-structure"
Expand Down

0 comments on commit a11abd4

Please sign in to comment.