2019-05-24 07:43:49 +00:00
|
|
|
; Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
; or more contributor license agreements. See the NOTICE file
|
|
|
|
; distributed with this work for additional information
|
|
|
|
; regarding copyright ownership. The ASF licenses this file
|
|
|
|
; to you under the Apache License, Version 2.0 (the
|
|
|
|
; "License"); you may not use this file except in compliance
|
|
|
|
; with the License. You may obtain a copy of the License at
|
|
|
|
;
|
|
|
|
; http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
;
|
|
|
|
; Unless required by applicable law or agreed to in writing, software
|
|
|
|
; distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
; See the License for the specific language governing permissions and
|
|
|
|
; limitations under the License.
|
|
|
|
(ns data-test.file-loader-test
|
|
|
|
(:require
|
|
|
|
[clojure.test :refer :all]
|
|
|
|
[clojure.java.io :as io]
|
|
|
|
[schema.core :as s]
|
|
|
|
[data-test.file-loader :as sut]))
|
|
|
|
|
2019-05-24 12:54:18 +00:00
|
|
|
(deftest should-read-test-data-spec
|
2019-05-24 07:43:49 +00:00
|
|
|
(is (= {:simple "test"}
|
2019-05-24 12:54:18 +00:00
|
|
|
(sut/read-test-data-spec (io/resource "simple_aero.edn"))))
|
2019-05-24 07:43:49 +00:00
|
|
|
(is (= {:to-be-refernced "ref-test", :key1 "ref-test", :key2 "ref-test"}
|
2019-05-24 12:54:18 +00:00
|
|
|
(sut/read-test-data-spec (io/resource "tagged_aero.edn"))))
|
2019-05-24 07:43:49 +00:00
|
|
|
)
|
|
|
|
|
2019-05-24 12:54:18 +00:00
|
|
|
(deftest should-calculate-data-test-spec-file-prefix
|
2019-05-24 07:43:49 +00:00
|
|
|
(is (= "data_test/file_loader_test/test_it"
|
2019-05-24 12:54:18 +00:00
|
|
|
(sut/data-test-spec-file-prefix ::test-it))))
|
2019-05-24 07:43:49 +00:00
|
|
|
|
2019-05-24 13:17:25 +00:00
|
|
|
(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))))
|
|
|
|
|
2019-05-24 07:43:49 +00:00
|
|
|
(deftest should-load-data
|
2019-05-28 16:53:08 +00:00
|
|
|
(is (= {:test "data"
|
|
|
|
:data-spec-file "data_test/file_loader_test/test_it.edn"}
|
2019-05-28 07:18:11 +00:00
|
|
|
(sut/load-data-test-spec (str (sut/data-test-spec-file-prefix ::test-it) ".edn")))))
|
|
|
|
|
|
|
|
(deftest should-not-load-non-existing-data
|
|
|
|
(is (= nil
|
|
|
|
(sut/load-data-test-spec (str (sut/data-test-spec-file-prefix ::not-existing) ".edn")))))
|
|
|
|
|
|
|
|
(deftest should-load-data-test-specs
|
2019-05-28 16:53:08 +00:00
|
|
|
(is (= [{:test "data"
|
|
|
|
:data-spec-file "data_test/file_loader_test/test_it.edn"}
|
|
|
|
{:test "data1"
|
|
|
|
:data-spec-file "data_test/file_loader_test/test_it.1.edn"}
|
|
|
|
{:test "data9"
|
|
|
|
:data-spec-file "data_test/file_loader_test/test_it.9.edn"}]
|
2019-05-28 07:18:11 +00:00
|
|
|
(sut/load-data-test-specs ::test-it))))
|
2019-05-24 07:43:49 +00:00
|
|
|
|
2019-05-24 11:17:59 +00:00
|
|
|
(deftest should-throw-exception
|
2019-05-24 11:31:12 +00:00
|
|
|
(is (thrown? RuntimeException
|
2019-05-28 07:18:11 +00:00
|
|
|
(sut/load-data-test-specs ::not-existing))))
|