|
50 | 50 | (deftest workspace-dir-name-test |
51 | 51 | (let [dir-name #'cache/workspace-dir-name] |
52 | 52 | (testing "prefixes hash with project name from first workspace URI" |
53 | | - (let [workspaces [{:uri "file:///home/user/my-project"}] |
| 53 | + (let [workspaces [{:uri "/home/user/my-project"}] |
54 | 54 | result (dir-name workspaces identity)] |
55 | 55 | (is (re-matches #"my-project_.{8}" result)))) |
56 | 56 |
|
57 | 57 | (testing "sanitizes unsafe filesystem characters" |
58 | | - (let [workspaces [{:uri "file:///home/user/my project@v2!"}] |
| 58 | + (let [workspaces [{:uri "/home/user/my project@v2!"}] |
59 | 59 | result (dir-name workspaces identity)] |
60 | 60 | (is (re-matches #"my_project_v2__.{8}" result)) |
61 | 61 | (is (nil? (re-find #"[ @!]" result))))) |
62 | 62 |
|
63 | 63 | (testing "truncates long project names to 30 chars" |
64 | 64 | (let [long-name (apply str (repeat 50 "a")) |
65 | | - workspaces [{:uri (str "file:///home/user/" long-name)}] |
| 65 | + workspaces [{:uri (str "/home/user/" long-name)}] |
66 | 66 | result (dir-name workspaces identity)] |
67 | 67 | (is (<= (count result) (+ 30 1 8))))) |
68 | 68 |
|
|
71 | 71 | (is (re-matches #".{8}" result)))) |
72 | 72 |
|
73 | 73 | (testing "uses first workspace name when multiple workspaces" |
74 | | - (let [workspaces [{:uri "file:///home/user/first-project"} |
75 | | - {:uri "file:///home/user/second-project"}] |
| 74 | + (let [workspaces [{:uri "/home/user/first-project"} |
| 75 | + {:uri "/home/user/second-project"}] |
76 | 76 | result (dir-name workspaces identity)] |
77 | 77 | (is (re-matches #"first-project_.{8}" result)))))) |
78 | 78 |
|
79 | 79 | (deftest workspace-cache-file-migration-test |
80 | 80 | (testing "migrates old hash-only directory to new format" |
81 | 81 | (with-temp-cache-dir |
82 | | - (let [workspaces [{:uri "file:///home/user/my-project"}] |
| 82 | + (let [workspaces [{:uri "/home/user/my-project"}] |
83 | 83 | hash-only (cache/workspaces-hash workspaces identity) |
84 | 84 | old-dir (io/file (cache/global-dir) hash-only)] |
85 | 85 | ;; Create old-format directory with a cache file |
|
94 | 94 |
|
95 | 95 | (testing "does not migrate when new directory already exists" |
96 | 96 | (with-temp-cache-dir |
97 | | - (let [workspaces [{:uri "file:///home/user/my-project"}] |
| 97 | + (let [workspaces [{:uri "/home/user/my-project"}] |
98 | 98 | hash-only (cache/workspaces-hash workspaces identity) |
99 | 99 | old-dir (io/file (cache/global-dir) hash-only) |
100 | 100 | result-before (cache/workspace-cache-file workspaces "db.transit.json" identity) |
|
0 commit comments