diff options
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/buffer-tests.el | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index 118311c4d26..059926ff46b 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el | |||
| @@ -1420,4 +1420,67 @@ with parameters from the *Messages* buffer modification." | |||
| 1420 | (remove-overlays) | 1420 | (remove-overlays) |
| 1421 | (should (= (length (overlays-in (point-min) (point-max))) 0)))) | 1421 | (should (= (length (overlays-in (point-min) (point-max))) 0)))) |
| 1422 | 1422 | ||
| 1423 | (ert-deftest test-kill-buffer-auto-save-default () | ||
| 1424 | (let ((file (make-temp-file "ert")) | ||
| 1425 | auto-save) | ||
| 1426 | (should (file-exists-p file)) | ||
| 1427 | ;; Always answer yes. | ||
| 1428 | (cl-letf (((symbol-function #'yes-or-no-p) (lambda (_) t))) | ||
| 1429 | (unwind-protect | ||
| 1430 | (progn | ||
| 1431 | (find-file file) | ||
| 1432 | (auto-save-mode t) | ||
| 1433 | (insert "foo\n") | ||
| 1434 | (should buffer-auto-save-file-name) | ||
| 1435 | (setq auto-save buffer-auto-save-file-name) | ||
| 1436 | (do-auto-save) | ||
| 1437 | (should (file-exists-p auto-save)) | ||
| 1438 | (kill-buffer (current-buffer)) | ||
| 1439 | (should (file-exists-p auto-save))) | ||
| 1440 | (ignore-errors (delete-file file)) | ||
| 1441 | (when auto-save | ||
| 1442 | (ignore-errors (delete-file auto-save))))))) | ||
| 1443 | |||
| 1444 | (ert-deftest test-kill-buffer-auto-save-delete () | ||
| 1445 | (let ((file (make-temp-file "ert")) | ||
| 1446 | auto-save) | ||
| 1447 | (should (file-exists-p file)) | ||
| 1448 | (setq kill-buffer-delete-auto-save-files t) | ||
| 1449 | ;; Always answer yes. | ||
| 1450 | (cl-letf (((symbol-function #'yes-or-no-p) (lambda (_) t))) | ||
| 1451 | (unwind-protect | ||
| 1452 | (progn | ||
| 1453 | (find-file file) | ||
| 1454 | (auto-save-mode t) | ||
| 1455 | (insert "foo\n") | ||
| 1456 | (should buffer-auto-save-file-name) | ||
| 1457 | (setq auto-save buffer-auto-save-file-name) | ||
| 1458 | (do-auto-save) | ||
| 1459 | (should (file-exists-p auto-save)) | ||
| 1460 | ;; This should delete the auto-save file. | ||
| 1461 | (kill-buffer (current-buffer)) | ||
| 1462 | (should-not (file-exists-p auto-save))) | ||
| 1463 | (ignore-errors (delete-file file)) | ||
| 1464 | (when auto-save | ||
| 1465 | (ignore-errors (delete-file auto-save))))) | ||
| 1466 | ;; Answer no to deletion. | ||
| 1467 | (cl-letf (((symbol-function #'yes-or-no-p) | ||
| 1468 | (lambda (prompt) | ||
| 1469 | (not (string-search "Delete auto-save file" prompt))))) | ||
| 1470 | (unwind-protect | ||
| 1471 | (progn | ||
| 1472 | (find-file file) | ||
| 1473 | (auto-save-mode t) | ||
| 1474 | (insert "foo\n") | ||
| 1475 | (should buffer-auto-save-file-name) | ||
| 1476 | (setq auto-save buffer-auto-save-file-name) | ||
| 1477 | (do-auto-save) | ||
| 1478 | (should (file-exists-p auto-save)) | ||
| 1479 | ;; This should not delete the auto-save file. | ||
| 1480 | (kill-buffer (current-buffer)) | ||
| 1481 | (should (file-exists-p auto-save))) | ||
| 1482 | (ignore-errors (delete-file file)) | ||
| 1483 | (when auto-save | ||
| 1484 | (ignore-errors (delete-file auto-save))))))) | ||
| 1485 | |||
| 1423 | ;;; buffer-tests.el ends here | 1486 | ;;; buffer-tests.el ends here |