|
23 | 23 | fs/absolute? (constantly true) |
24 | 24 | fs/exists? (constantly true) |
25 | 25 | fs/canonicalize identity |
26 | | - fs/file-name (fn [p] (last (string/split p #"/")))] |
27 | | - (let [config {:rules [{:path "/path/to/my-rule.md"}]}] |
| 26 | + fs/file-name (constantly "cool-name")] |
| 27 | + (let [config {:rules [{:path (h/file-path "/path/to/my-rule.md")}]}] |
28 | 28 | (is (match? |
29 | 29 | (m/embeds [{:type :user-config |
30 | | - :path "/path/to/my-rule.md" |
31 | | - :name "my-rule.md" |
| 30 | + :path (h/file-path "/path/to/my-rule.md") |
| 31 | + :name "cool-name" |
32 | 32 | :content "MY_RULE_CONTENT"}]) |
33 | 33 | (f.rules/all config [] vars)))))) |
34 | 34 |
|
|
37 | 37 | fs/exists? (constantly true) |
38 | 38 | fs/list-dir (constantly []) |
39 | 39 | fs/canonicalize identity |
40 | | - fs/file-name (fn [p] (last (string/split (str p) (re-pattern fs/file-separator)))) |
| 40 | + fs/file-name (constantly "cool-name") |
41 | 41 | clojure.core/slurp (constantly "MY_RULE_CONTENT")] |
42 | 42 | (let [config {:rules [{:path ".foo/cool-rule.md"}]} |
43 | 43 | roots [{:uri (h/file-uri "file:///my/project")}]] |
44 | 44 | (is (match? |
45 | | - (m/embeds [{:type :user-config |
46 | | - :path (h/file-path "/my/project/.foo/cool-rule.md") |
47 | | - :name "cool-rule.md" |
48 | | - :content "MY_RULE_CONTENT"}]) |
49 | | - (f.rules/all config roots vars)))))) |
| 45 | + (m/embeds [{:type :user-config |
| 46 | + :path (h/file-path "/my/project/.foo/cool-rule.md") |
| 47 | + :name "cool-name" |
| 48 | + :content "MY_RULE_CONTENT"}]) |
| 49 | + (f.rules/all config roots vars)))))) |
50 | 50 |
|
51 | 51 | (testing "file rules" |
52 | 52 | (with-redefs [fs/exists? (constantly true) |
53 | | - fs/list-dir (constantly [(fs/path "cool-rule.md")]) |
| 53 | + fs/list-dir (constantly [(fs/path "cool.md")]) |
54 | 54 | fs/canonicalize identity |
55 | | - fs/file-name (fn [p] (last (string/split (str p) #"/"))) |
| 55 | + fs/file-name (constantly "cool-name") |
56 | 56 | clojure.core/slurp (constantly "MY_RULE_CONTENT")] |
57 | 57 | (let [roots [{:uri (h/file-uri "file:///my/project")}]] |
58 | 58 | (is (match? |
59 | 59 | (m/embeds [{:type :user-file |
60 | | - :path "cool-rule.md" |
61 | | - :name "cool-rule.md" |
| 60 | + :path "cool.md" |
| 61 | + :name "cool-name" |
62 | 62 | :content "MY_RULE_CONTENT"}]) |
63 | 63 | (f.rules/all {} roots vars)))))))) |
0 commit comments