|
272 | 272 | (expect (cider-repls) :to-equal (list bb2 bb1))
|
273 | 273 | (expect (cider-repls 'cljs) :to-equal (list bb2)))))))))))))
|
274 | 274 |
|
| 275 | + (describe "when multiple sessions exist and cider-merge-sessions is set to :project" |
| 276 | + (it "always returns all connections associated with a project" |
| 277 | + (let ((proj-dir (expand-file-name "/tmp/proj-dir")) |
| 278 | + (cider-merge-sessions 'project)) |
| 279 | + (let ((default-directory proj-dir)) |
| 280 | + (with-repl-buffer ses-name 'clj bb1 |
| 281 | + (with-repl-buffer ses-name 'cljs bb2 |
| 282 | + (with-repl-buffer ses-name2 'clj b1 |
| 283 | + (with-repl-buffer ses-name2 'cljs b2 |
| 284 | + |
| 285 | + (expect (cider-repls) :to-have-same-items-as (list b2 b1 bb2 bb1)) |
| 286 | + |
| 287 | + (switch-to-buffer bb1) |
| 288 | + (expect (cider-repls) :to-have-same-items-as (list b2 b1 bb2 bb1)) |
| 289 | + |
| 290 | + ;; follows type arguments |
| 291 | + (expect (cider-repls 'clj) :to-have-same-items-as (list b1 bb1)) |
| 292 | + (expect (cider-repls 'cljs) :to-have-same-items-as (list b2 bb2)) |
| 293 | + |
| 294 | + (switch-to-buffer bb2) |
| 295 | + ;; follows file type |
| 296 | + (with-temp-buffer |
| 297 | + (setq major-mode 'clojure-mode) |
| 298 | + (expect (cider-repls) :to-have-same-items-as (list b2 b1 bb2 bb1)) |
| 299 | + (expect (cider-repls 'clj) :to-have-same-items-as (list b1 bb1))) |
| 300 | + |
| 301 | + (with-temp-buffer |
| 302 | + (setq major-mode 'clojurescript-mode) |
| 303 | + (expect (cider-repls) :to-have-same-items-as (list b2 b1 bb2 bb1)) |
| 304 | + (expect (cider-repls 'cljs) :to-have-same-items-as (list b2 bb2)))))))))) |
| 305 | + (it "only returns the connections of the active project" |
| 306 | + (let ((a-dir (expand-file-name "/tmp/a-dir")) |
| 307 | + (b-dir (expand-file-name "/tmp/b-dir")) |
| 308 | + (cider-merge-sessions 'project)) |
| 309 | + (let ((default-directory a-dir)) |
| 310 | + (with-repl-buffer ses-name 'clj bb1 |
| 311 | + (with-repl-buffer ses-name 'cljs bb2 |
| 312 | + (let ((default-directory b-dir)) |
| 313 | + (with-repl-buffer ses-name2 'clj b1 |
| 314 | + (with-repl-buffer ses-name2 'cljs b2 |
| 315 | + |
| 316 | + (expect (cider-repls) :to-have-same-items-as (list b2 b1)) |
| 317 | + |
| 318 | + (switch-to-buffer bb1) |
| 319 | + (expect (cider-repls) :to-have-same-items-as (list bb2 bb1)) |
| 320 | + |
| 321 | + ;; follows type arguments |
| 322 | + (expect (cider-repls 'clj) :to-have-same-items-as (list bb1)) |
| 323 | + (expect (cider-repls 'cljs) :to-have-same-items-as (list bb2)) |
| 324 | + |
| 325 | + (switch-to-buffer bb2) |
| 326 | + ;; follows file type |
| 327 | + (let ((default-directory b-dir)) |
| 328 | + (with-temp-buffer |
| 329 | + (setq major-mode 'clojure-mode) |
| 330 | + (expect (cider-repls) :to-have-same-items-as (list b2 b1)) |
| 331 | + (expect (cider-repls 'clj) :to-have-same-items-as (list b1)))) |
| 332 | + |
| 333 | + (let ((default-directory a-dir)) |
| 334 | + (with-temp-buffer |
| 335 | + (setq major-mode 'clojurescript-mode) |
| 336 | + (expect (cider-repls) :to-have-same-items-as (list bb2 bb1)) |
| 337 | + (expect (cider-repls 'cljs) :to-have-same-items-as (list bb2))))))))))))) |
| 338 | + |
| 339 | + (describe "when multiple sessions exist and cider-combine-merge-sessions is set to :host" |
| 340 | + (before-each |
| 341 | + (spy-on 'cider--gather-session-params :and-call-fake (lambda (session) |
| 342 | + (if (string-equal (car session) "local") |
| 343 | + '(:host "localhost") |
| 344 | + '(:host "remotehost"))))) |
| 345 | + (it "returns only the sessions associated with the current session's host" |
| 346 | + (let ((cider-merge-sessions 'host) |
| 347 | + (local-session "local") |
| 348 | + (remote-session "remote") |
| 349 | + (proj-dir (expand-file-name "/tmp/proj-dir"))) |
| 350 | + (let ((default-directory proj-dir)) |
| 351 | + (with-repl-buffer local-session 'clj l1 |
| 352 | + (with-repl-buffer local-session 'clj l2 |
| 353 | + (with-repl-buffer remote-session 'clj r1 |
| 354 | + (switch-to-buffer r1) |
| 355 | + (expect (cider-repls) :to-have-same-items-as (list r1)) |
| 356 | + (switch-to-buffer l1) |
| 357 | + (expect (cider-repls) :to-have-same-items-as (list l1 l2))))))))) |
| 358 | + |
275 | 359 | (describe "killed buffers"
|
276 | 360 | (it "do not show up in it"
|
277 | 361 | (let ((default-directory (expand-file-name "/tmp/some-dir")))
|
|
0 commit comments