|
48 | 48 | result (with-env env #(config/resolve-config opts))] |
49 | 49 | (is (= cfg-path (:config-path result))) |
50 | 50 | (is (= "cli-repo" (:graph result))) |
51 | | - (is (= "cli-root" (:root-dir result))) |
| 51 | + (is (= (node-path/resolve "cli-root") (:root-dir result))) |
52 | 52 | (is (= 333 (:timeout-ms result))) |
53 | 53 | (is (= 888 (:login-timeout-ms result))) |
54 | 54 | (is (= 999 (:logout-timeout-ms result))) |
|
65 | 65 | "LOGSEQ_CLI_ROOT_DIR" "env-root"} |
66 | 66 | result (with-env env #(config/resolve-config {:config-path cfg-path}))] |
67 | 67 | (is (= "env-repo" (:graph result))) |
68 | | - (is (= "env-root" (:root-dir result))))) |
| 68 | + (is (= (node-path/resolve "env-root") (:root-dir result))))) |
69 | 69 |
|
70 | 70 | (deftest test-output-format-env-overrides-file |
71 | 71 | (let [dir (node-helper/create-tmp-dir) |
|
110 | 110 | "LOGSEQ_CLI_CONFIG" nil} |
111 | 111 | #(config/resolve-config {:config-path cfg-path}))] |
112 | 112 | (is (= cfg-path (:config-path result))) |
113 | | - (is (= "~/logseq" (:root-dir result))) |
| 113 | + (is (= (node-path/join (.homedir os) "logseq") (:root-dir result))) |
114 | 114 | (is (= "wss://api.logseq.io/sync/%s" (:ws-url result))) |
115 | 115 | (is (= "https://api.logseq.io" (:http-base result))) |
116 | 116 | (is (= 10000 (:timeout-ms result))) |
|
127 | 127 | "LOGSEQ_CLI_OUTPUT" nil |
128 | 128 | "LOGSEQ_CLI_CONFIG" nil} |
129 | 129 | #(config/resolve-config {:root-dir "~/custom-logseq"}))] |
130 | | - (is (= "~/custom-logseq" (:root-dir result))) |
131 | | - (is (= (node-path/join "~/custom-logseq" "cli.edn") |
| 130 | + (is (= (node-path/join (.homedir os) "custom-logseq") (:root-dir result))) |
| 131 | + (is (= (node-path/join (.homedir os) "custom-logseq" "cli.edn") |
132 | 132 | (:config-path result))))) |
133 | 133 |
|
134 | 134 | (deftest test-explicit-config-path-does-not-change-root-dir-derived-defaults |
|
137 | 137 | result (config/resolve-config {:config-path cfg-path |
138 | 138 | :root-dir "~/custom-logseq"})] |
139 | 139 | (is (= cfg-path (:config-path result))) |
140 | | - (is (= "~/custom-logseq" (:root-dir result))))) |
| 140 | + (is (= (node-path/join (.homedir os) "custom-logseq") (:root-dir result))))) |
141 | 141 |
|
142 | 142 | (deftest test-server-list-path-follows-root-dir |
143 | 143 | (let [root-dir (node-path/join (node-helper/create-tmp-dir "cli-root") "nested-root") |
|
202 | 202 | parsed (reader/read-string contents)] |
203 | 203 | (is (= "old" (:graph parsed))) |
204 | 204 | (is (not (contains? parsed :auth-token))))) |
| 205 | + |
| 206 | +(deftest test-update-config-expands-tilde-in-root-dir |
| 207 | + (let [dir (node-helper/create-tmp-dir "cli-tilde") |
| 208 | + cfg-path (node-path/join dir "cli.edn") |
| 209 | + _ (config/update-config! {:root-dir dir} {:ws-url "wss://example.com"}) |
| 210 | + contents (.toString (fs/readFileSync cfg-path) "utf8") |
| 211 | + parsed (reader/read-string contents)] |
| 212 | + (is (= "wss://example.com" (:ws-url parsed))))) |
0 commit comments