|
1 | 1 | (ns ^{:author "Vladislav Bauer"}
|
2 | 2 | lein-plantuml.t-core
|
3 | 3 | (:import (net.sourceforge.plantuml FileFormat))
|
4 |
| - (:use [midje.sweet :only [fact]] |
5 |
| - [midje.util :only [testable-privates]] |
6 |
| - [clojure.java.io :only [as-file]]) |
7 |
| - (:require [lein-plantuml.core :as core] |
8 |
| - [me.raynes.fs :as fs])) |
| 4 | + (:use [clojure.java.io :only [as-file]] |
| 5 | + [clojure.test :only [deftest is]]) |
| 6 | + (:require [me.raynes.fs :as fs] |
| 7 | + [lein-plantuml.core :as core])) |
9 | 8 |
|
10 | 9 |
|
11 | 10 | ; Configurations
|
12 | 11 |
|
13 | 12 | (def ^:private DEF_OUTPUT "test-out")
|
14 | 13 |
|
15 |
| -(testable-privates |
16 |
| - lein-plantuml.core |
17 |
| - file-format |
18 |
| - read-configs |
19 |
| - process-file |
20 |
| - FILE_FORMAT) |
21 |
| - |
22 | 14 |
|
23 | 15 | ; Helper functions
|
24 | 16 |
|
25 | 17 | (defn- clear-output[]
|
26 | 18 | (fs/delete-dir DEF_OUTPUT))
|
27 | 19 |
|
28 | 20 | (defn- check-formats [& names]
|
29 |
| - (let [formats (distinct (map file-format names)) |
| 21 | + (let [formats (distinct (map core/file-format names)) |
30 | 22 | eq (= 1 (count formats))]
|
31 | 23 | (if eq
|
32 | 24 | (first formats)
|
33 | 25 | (throw (Exception. "Incorrect file-format function")))))
|
34 | 26 |
|
35 | 27 | (defn- check-process
|
36 | 28 | ([u] (let [file (str "example/doc/" u)
|
37 |
| - formats (vals (var-get FILE_FORMAT))] |
| 29 | + formats (vals core/FILE_FORMAT)] |
38 | 30 | (every? #(check-process file %) formats)))
|
39 | 31 | ([u f] (try
|
40 | 32 | (do
|
41 | 33 | (clear-output)
|
42 |
| - (process-file u DEF_OUTPUT f)) |
| 34 | + (core/process-file u DEF_OUTPUT f)) |
43 | 35 | (finally (clear-output)))))
|
44 | 36 |
|
45 | 37 |
|
46 | 38 | ; Tests
|
47 | 39 |
|
48 |
| -(fact "Check available file formats" |
49 |
| - (check-formats nil :none) => nil |
50 |
| - (check-formats :eps :EPS "eps" "EPS") => FileFormat/EPS |
51 |
| - (check-formats :eps:txt "eps:txt") => FileFormat/EPS_TEXT |
52 |
| - (check-formats :png "png") => FileFormat/PNG |
53 |
| - (check-formats :txt "txt") => FileFormat/ATXT |
54 |
| - (check-formats :utxt "utxt") => FileFormat/UTXT |
55 |
| - (check-formats :svg "SVG") => FileFormat/SVG |
| 40 | +(deftest check-available-file-formats |
| 41 | + (is (= (check-formats nil :none) nil)) |
| 42 | + (is (= (check-formats :eps :EPS "eps" "EPS") FileFormat/EPS)) |
| 43 | + (is (= (check-formats :eps:txt "eps:txt") FileFormat/EPS_TEXT)) |
| 44 | + (is (= (check-formats :png "png") FileFormat/PNG)) |
| 45 | + (is (= (check-formats :txt "txt") FileFormat/ATXT)) |
| 46 | + (is (= (check-formats :utxt "utxt") FileFormat/UTXT)) |
| 47 | + (is (= (check-formats :svg "SVG") FileFormat/SVG)) |
56 | 48 | ; TODO: The following formats are very unstable:
|
57 | 49 | ;(check-formats :pdf) => FileFormat/PDF
|
58 | 50 | ;(check-formats :html) => FileFormat/HTML
|
59 | 51 | ;(check-formats :html5) => FileFormat/HTML5
|
60 | 52 | )
|
61 | 53 |
|
62 |
| -(fact "Check source list" |
63 |
| - (empty? (read-configs nil)) => true |
64 |
| - (empty? (read-configs {})) => true |
65 |
| - (empty? (read-configs {:plantuml []})) => true |
66 |
| - (empty? (read-configs {:plantuml ["test.uml"]})) => false |
67 |
| - (empty? (read-configs {} "test.uml")) => false |
68 |
| - (empty? (read-configs {} ["test.uml"])) => false |
69 |
| - (empty? (read-configs {:plantuml ["test.uml"]} ["test.uml"])) => false) |
| 54 | +(deftest check-source-list |
| 55 | + (let [read-conf core/read-configs] |
| 56 | + (is (= (empty? (read-conf nil)) true)) |
| 57 | + (is (= (empty? (read-conf {})) true)) |
| 58 | + (is (= (empty? (read-conf {:plantuml []})) true)) |
| 59 | + (is (= (empty? (read-conf {:plantuml ["test.uml"]})) false)) |
| 60 | + (is (= (empty? (read-conf {} "test.uml")) false)) |
| 61 | + (is (= (empty? (read-conf {} ["test.uml"])) false)) |
| 62 | + (is (= (empty? (read-conf {:plantuml ["test.uml"]} ["test.uml"])) false)))) |
70 | 63 |
|
71 |
| -(fact "Check PlantUML processor" |
72 |
| - (check-process "example-01.puml") => true |
73 |
| - (check-process "example-02.puml") => true |
74 |
| - (check-process "example-03.puml") => true |
75 |
| - (check-process "example-04.puml") => true) |
| 64 | +(deftest check-plantuml-processor |
| 65 | + (is (= (check-process "example-01.puml") true)) |
| 66 | + (is (= (check-process "example-02.puml") true)) |
| 67 | + (is (= (check-process "example-03.puml") true)) |
| 68 | + (is (= (check-process "example-04.puml") true))) |
0 commit comments