Init basic tests

This commit is contained in:
Jaidyn Ann 2024-05-27 23:59:55 -05:00
parent 199dc99c36
commit 0b4ceff91f
3 changed files with 63 additions and 1 deletions

View File

@ -18,3 +18,9 @@ build:
--eval '(ql:quickload :mirror-img/unix)' \ --eval '(ql:quickload :mirror-img/unix)' \
--eval '(asdf:make :mirror-img/unix)' \ --eval '(asdf:make :mirror-img/unix)' \
--eval '(quit)' --eval '(quit)'
test:
$(LISP) --load mirror-img.asd \
--eval '(ql:quickload :mirror-img)' \
--eval '(asdf:test-system :mirror-img)' \
--eval '(quit)'

View File

@ -6,7 +6,8 @@
:author "Jaidyn Ann <jadedctrl@posteo.at>" :author "Jaidyn Ann <jadedctrl@posteo.at>"
:depends-on (:dexador :lquery :split-sequence) :depends-on (:dexador :lquery :split-sequence)
:components ((:file "src/mirror-img")) :components ((:file "src/mirror-img"))
:in-order-to ((build-op (build-op "mirror-img/unix")))) :in-order-to ((test-op (test-op "mirror-img/tests"))
(build-op (build-op "mirror-img/unix"))))
(asdf:defsystem "mirror-img/unix" (asdf:defsystem "mirror-img/unix"
:version "0.1" :version "0.1"
@ -18,3 +19,22 @@
:entry-point "mirror-img/unix:main" :entry-point "mirror-img/unix:main"
:depends-on (:mirror-img :unix-opts :cl-strings) :depends-on (:mirror-img :unix-opts :cl-strings)
:components ((:file "src/unix"))) :components ((:file "src/unix")))
;;; Tests
;;; —————————————————————————————————————
(asdf:defsystem "mirror-img/tests"
:version "0.1"
:license "GPLv3"
:author "Jaidyn Ann <jadedctrl@posteo.at>"
:description "Tests for the the mirror-img package."
:depends-on (:mirror-img :lisp-unit2)
:components ((:file "t/mirror-img")))
;; Following method borrowed from lisp-unit2s documentation:
;; https://github.com/AccelerationNet/lisp-unit2/blob/master/README.md#asdf
(defmethod asdf:perform ((o asdf:test-op) (c (eql (asdf:find-system :mirror-img/tests))))
(eval (read-from-string
"(lisp-unit2:with-summary ()
(lisp-unit2:run-tests :package :mirror-img/tests))")))

36
t/mirror-img.lisp Normal file
View File

@ -0,0 +1,36 @@
;;;; mirror-img/tests: Tests for the mirror-img package.
;; Copyright © 2024 Jaidyn Ann <jadedctrl@posteo.at>
;;
;; This program is free software: you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, either version 3 of
;; the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(defpackage :mirror-img/tests
(:use :cl :lisp-unit2))
(in-package :mirror-img/tests)
(define-test mirrored-pathname (:tags '(base))
(assert-equal
(mirror-img::mirrored-pathname "https://invalid.tld/dir/bird apple.txt" #p"base/")
#p"base/invalid.tld/bird apple.txt"))
(define-test url-encode-uri.space (:tags '(util))
(assert-equal
(mirror-img::url-encode-uri "https://invalid.tld/dad alive.jpg")
"https://invalid.tld/dad%20alive.jpg"))
(define-test url-encode-path.space+exclamation (:tags '(util))
(assert-equal
(mirror-img::url-encode-path "/images!/dad alive.jpg")
"/images%21/dad%20alive.jpg"))