add option to load more than one test-spec

This commit is contained in:
jem 2019-05-24 15:17:25 +02:00
parent d4a5690a88
commit 9503aeddaf
2 changed files with 20 additions and 5 deletions

View file

@ -36,9 +36,12 @@
#"-" "_")
#"\." "/"))
(s/defn find-data-spec-files :- [s/Any]
[data-test-spec-file-prefix :- s/Str]
(.listFiles (io/resource (str data-test-spec-file-prefix "*.edn"))))
(s/defn data-test-spec-file-names :- [s/Str]
[name-key :- s/Keyword]
(let [prefix (data-test-spec-file-prefix name-key)]
(cons (str prefix ".edn")
(map #(str prefix "." % ".edn")
(range 10)))))
(s/defn load-test-data
[file-prefix :- s/Str]

View file

@ -31,6 +31,20 @@
(is (= "data_test/file_loader_test/test_it"
(sut/data-test-spec-file-prefix ::test-it))))
(deftest should-list-all-posible-resources
(is (= '("data_test/file_loader_test/test_it.edn"
"data_test/file_loader_test/test_it.0.edn"
"data_test/file_loader_test/test_it.1.edn"
"data_test/file_loader_test/test_it.2.edn"
"data_test/file_loader_test/test_it.3.edn"
"data_test/file_loader_test/test_it.4.edn"
"data_test/file_loader_test/test_it.5.edn"
"data_test/file_loader_test/test_it.6.edn"
"data_test/file_loader_test/test_it.7.edn"
"data_test/file_loader_test/test_it.8.edn"
"data_test/file_loader_test/test_it.9.edn")
(sut/data-test-spec-file-names ::test-it))))
(deftest should-load-data
(is (= {:test "data"}
(sut/load-test-data (sut/data-test-spec-file-prefix ::test-it)))))
@ -38,5 +52,3 @@
(deftest should-throw-exception
(is (thrown? RuntimeException
(sut/load-test-data (sut/data-test-spec-file-prefix ::not-existing)))))
;(sut/find-data-spec-files (sut/data-test-spec-file-prefix ::test-it))