|
| 1 | +(local {: describe : it : before_each} (require :plenary.busted)) |
| 2 | +(local assert (require :luassert.assert)) |
| 3 | +(local log (require :conjure.log)) |
| 4 | +(local client (require :conjure.client)) |
| 5 | +(local config (require :conjure.config)) |
| 6 | +(local vim _G.vim) |
| 7 | + |
| 8 | +(describe "log-buf?" |
| 9 | + (fn [] |
| 10 | + (before_each |
| 11 | + (fn [] |
| 12 | + (config.assoc-in [:log :linked_to_client_state] false) |
| 13 | + (tset client.state :state-key-set? false))) |
| 14 | + |
| 15 | + (describe "linked_to_client_state disabled" |
| 16 | + (fn [] |
| 17 | + (it "matches a buffer named with the PID" |
| 18 | + (fn [] |
| 19 | + (client.with-filetype :fennel |
| 20 | + #(assert.is_true |
| 21 | + (log.log-buf? (.. "conjure-log-" (vim.fn.getpid) ".fnl")))))) |
| 22 | + |
| 23 | + (it "does not match a buffer named with a state key" |
| 24 | + (fn [] |
| 25 | + (client.set-state-key! :my-feature) |
| 26 | + (client.with-filetype :fennel |
| 27 | + #(assert.is_false (log.log-buf? "conjure-log-my-feature.fnl"))))))) |
| 28 | + |
| 29 | + (describe "linked_to_client_state enabled with state key set" |
| 30 | + (fn [] |
| 31 | + (before_each |
| 32 | + (fn [] |
| 33 | + (config.assoc-in [:log :linked_to_client_state] true) |
| 34 | + (client.set-state-key! :my-feature))) |
| 35 | + |
| 36 | + (it "matches a buffer named with the state key" |
| 37 | + (fn [] |
| 38 | + (client.with-filetype :fennel |
| 39 | + #(assert.is_true (log.log-buf? "conjure-log-my-feature.fnl"))))) |
| 40 | + |
| 41 | + (it "does not match a buffer named with the PID" |
| 42 | + (fn [] |
| 43 | + (client.with-filetype :fennel |
| 44 | + #(assert.is_false |
| 45 | + (log.log-buf? (.. "conjure-log-" (vim.fn.getpid) ".fnl")))))))) |
| 46 | + |
| 47 | + (describe "linked_to_client_state enabled but no state key set" |
| 48 | + (fn [] |
| 49 | + (before_each |
| 50 | + (fn [] |
| 51 | + (config.assoc-in [:log :linked_to_client_state] true))) |
| 52 | + |
| 53 | + (it "falls back to matching a buffer named with the PID" |
| 54 | + (fn [] |
| 55 | + (client.with-filetype :fennel |
| 56 | + #(assert.is_true |
| 57 | + (log.log-buf? (.. "conjure-log-" (vim.fn.getpid) ".fnl")))))))))) |
0 commit comments