summaryrefslogtreecommitdiff
path: root/tests/test-fs-format-file-info.el
blob: b5a82f4babfe9c9110f163facad913a916fbc4a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
;;; test-tool-library-fs-format-file-info.el --- ERT tests for cj/fs-format-file-info -*- lexical-binding: t; -*-

;; Author: gptel-tool-writer and cjennings
;; Keywords: tests, filesystem, tools

;;; Commentary:
;; ERT tests for the cj/fs-format-file-info function from tool-filesystem-library.el.
;; Place this file in ~/.emacs.d/tests/ and load it to run tests.

;;; Code:

(require 'ert)
(require 'f)
(require 'tool-filesystem-library)

(ert-deftest test-cj/fs-format-file-info-normal-typical ()
  "Normal: format typical file info plist."
  (let ((info (list :permissions "-rw-r--r--"
                    :executable nil
                    :size 1024
                    :last-modified (current-time)
                    :path "~/test-file.txt")))
	(should (string-match-p "test-file.txt" (cj/fs-format-file-info info "~")))))

(ert-deftest test-cj/fs-format-file-info-error-missing-keys ()
  "Error: format with missing keys handled."
  (let ((info (list)))
	(should (cj/fs-format-file-info info "~"))))

(ert-deftest test-cj/fs-format-file-info-boundary-zero-size ()
  "Boundary: format with zero size."
  (let ((info (list :permissions "-rw-r--r--"
					:executable nil
					:size 0
					:last-modified (current-time)
					:path "~/empty-file.txt")))
	(should (string-match-p "empty-file.txt" (cj/fs-format-file-info info "~")))))

(provide 'test-tool-library-fs-format-file-info)
;;; test-tool-library-fs-format-file-info.el ends here