Skip to content

Commit

Permalink
Bumping example project, fixing report icons, more robust example
Browse files Browse the repository at this point in the history
project testing
  • Loading branch information
oliyh committed Jul 10, 2020
1 parent d1405ab commit be89805
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
4 changes: 2 additions & 2 deletions example/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[org.clojure/clojurescript "1.10.520"]
[reagent "0.8.1"]
[devcards "0.2.6"]
[kamera "0.1.1-SNAPSHOT"]]
[kamera "0.1.3-SNAPSHOT"]]

:source-paths ["src"]
:resource-paths ["resources"]
Expand All @@ -20,5 +20,5 @@
"fig:min" ["run" "-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]
"fig:test" ["run" "-m" "figwheel.main" "-co" "test.cljs.edn" "-m" example.test-runner]}

:profiles {:dev {:dependencies [[com.bhauman/figwheel-main "0.1.9"]
:profiles {:dev {:dependencies [[com.bhauman/figwheel-main "0.2.9"]
[com.bhauman/rebel-readline-cljs "0.1.4"]]}})
Binary file modified example/test-resources/kamera/example.core_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
"resources/public/kamera.js"]
:plugins [[lein-sass "0.4.0"]]}
:repl {:prep-tasks ^:replace []}
:build {:prep-tasks ^:replace []}}
:build {:prep-tasks ^:replace []}
:example-test {:prep-tasks ^:replace []
:source-paths ["test-resources"]}}

:sass {:src "resources/sass"
:output-directory "resources/public/css"}
Expand Down
4 changes: 2 additions & 2 deletions resources/sass/kamera.scss
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ body {
}

.step-name.expanded:before {
content: 'remove_circle_outline';
content: '\e15d';
}

.step-name.contracted:before {
content: 'add_circle_outline';
content: '\e148';
}

.step-name {
Expand Down
4 changes: 3 additions & 1 deletion test-example-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ if [ $? -eq 0 ]; then
exit 1;
else
echo "Example project failed as expected"

FILE=./target/kamera/results.edn
if [ -f "$FILE" ]; then
echo "Report $FILE generated as expected";
echo "Report $FILE generated as expected, running assertions";
cd .. && lein with-profile +example-test run -m assert-example-results
else
echo "Report $FILE was not generated, failing";
exit 1;
Expand Down
28 changes: 28 additions & 0 deletions test-resources/assert_example_results.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(ns assert-example-results
(:require [clojure.edn :as edn]
[clojure.test :refer [deftest testing is run-tests successful?]]))

(deftest example-report-test []
(let [{:keys [results] :as report} (edn/read-string (slurp "example/target/kamera/results.edn"))]
(is report)
(is (= 2 (count results)))

(testing "first devcard fails on purpose"
(let [result (first results)]
(is (false? (:passed? result)))
(is (pos? (:metric result)))
(is (= "example.another_core_test.png"
(get-in result [:target :reference-file])))))

(testing "second devcard passes"
(let [result (second results)]
(is (true? (:passed? result)))
(is (< (:metric result) 0.05))
(is (= "example.core_test.png"
(get-in result [:target :reference-file])))))))

(defn -main [& args]
(let [test-report (run-tests 'assert-example-results)]
(println "Example project results:" test-report)
(when-not (successful? test-report)
(System/exit 1))))

0 comments on commit be89805

Please sign in to comment.