Skip to content

Commit 2197317

Browse files
committed
fix: Mock file-writable-p in not-writable test
The previous test relied on file permissions (mode 444) to make file-writable-p return nil. However, with-temp-file writes to a temp file and renames, which succeeds if you own the file, causing file-writable-p to still return t. Use spy-on to mock file-writable-p instead.
1 parent 8ed7145 commit 2197317

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/cider-repl-tests.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,10 @@ PROPERTY should be a symbol of either 'text, 'ansi-context or
329329
(cider-repl-history-size 100))
330330
(unwind-protect
331331
(progn
332-
;; Create a read-only file
333332
(write-region "" nil history-file)
334-
(set-file-modes history-file #o444)
333+
;; Mock file-writable-p to return nil for this specific file
334+
(spy-on 'file-writable-p :and-call-fake
335+
(lambda (f) (not (string= f history-file))))
335336
(expect (cider-repl--history-write history-file)
336337
:to-throw 'error))
337-
(set-file-modes history-file #o644)
338338
(delete-directory temp-dir t))))))

0 commit comments

Comments
 (0)