Skip to content

Commit

Permalink
feat(tests): a couple more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
goshatch committed Mar 14, 2024
1 parent d386b9c commit 534242e
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions tests/test-util.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,28 @@
(is (string= (homestead/util:join list " | ") "a | b"))))

(test slurp
(let ((missing-file "/tmp/bob.txt"))
(is (equal '() (homestead/util:slurp missing-file)))))
(let ((missing-file "/tmp/homestead-test-utils-slurp-missing-file.txt"))
(is (equal '() (homestead/util:slurp missing-file))))
(let ((test-file "/tmp/homestead-test-utils-slurp-test-file.txt"))
(with-open-file (out test-file
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(format out "Hello, World!!!"))
(let ((content (homestead/util:slurp test-file)))
(is (string= content (format nil "Hello, World!!!~%"))))))

(test merge-plists
(let* ((plist1 '(:a "a" :b "b"))
(plist2 '(:c "c" :d "d"))
(merged (homestead/util:merge-plists plist1 plist2)))
(is (string= (getf merged :a) "a"))
(is (string= (getf merged :b) "b"))
(is (string= (getf merged :c) "c"))
(is (string= (getf merged :d) "d")))
(let* ((plist1 '(:a "a" :b "b"))
(plist2 '(:b "bee" :c "c"))
(merged (homestead/util:merge-plists plist1 plist2)))
(is (string= (getf merged :a) "a"))
(is (string= (getf merged :b) "bee"))
(is (string= (getf merged :c) "c"))))

0 comments on commit 534242e

Please sign in to comment.