testing improvements; start with util/iter
This commit is contained in:
parent
b264886c17
commit
99586247de
7 changed files with 36 additions and 17 deletions
|
@ -11,7 +11,7 @@
|
|||
:env-path (t:test-path ".test.env"))
|
||||
|
||||
(config:add :logger :class 'logging:config
|
||||
:loglevel :info
|
||||
:loglevel :debug
|
||||
:logfile (t:test-path "scopes-test.log" "log")
|
||||
:console nil)
|
||||
|
||||
|
|
|
@ -46,5 +46,5 @@
|
|||
(deftest test-client (client)
|
||||
(let ((msg (message:create
|
||||
'(:auth :login)
|
||||
:data '(:name "admin" :password "sc0pes"))))
|
||||
:data '(:org "system" :name "admin" :password "sc0pes"))))
|
||||
(client:send-message client msg)))
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
(:use :common-lisp)
|
||||
(:local-nicknames (:auth :scopes-auth)
|
||||
(:config :scopes/config)
|
||||
(:core :scopes/core))
|
||||
(:core :scopes/core)
|
||||
(:util :scopes/util))
|
||||
(:export #:login))
|
||||
|
||||
(in-package :scopes-auth/web)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
(:file "shape/shape")
|
||||
(:file "util/util")
|
||||
(:file "util/crypt" :depends-on ("util/util"))
|
||||
(:file "util/iter")
|
||||
(:file "testing" :depends-on ("util/util")))
|
||||
:long-description "scopes/core: The core packages of the scopes project."
|
||||
:in-order-to ((test-op (test-op "scopes-core/test"))))
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
(:config :scopes/config)
|
||||
(:core :scopes/core)
|
||||
(:crypt :scopes/util/crypt)
|
||||
(:iter :scopes/util/iter)
|
||||
(:logging :scopes/logging)
|
||||
(:message :scopes/core/message)
|
||||
(:shape :scopes/shape)
|
||||
|
@ -55,7 +56,9 @@
|
|||
(unwind-protect
|
||||
(progn
|
||||
(test-util)
|
||||
(test-record)
|
||||
(test-util-crypt)
|
||||
(test-util-iter)
|
||||
(test-shape)
|
||||
(core:setup-services)
|
||||
(setf (receiver t:*test-suite*) (core:find-service :test-receiver))
|
||||
(test-send))
|
||||
|
@ -64,7 +67,6 @@
|
|||
(t:show-result))))
|
||||
|
||||
(deftest test-util ()
|
||||
(util:lgi (crypt:create-secret))
|
||||
(let ((now (get-universal-time)))
|
||||
(== (util:from-unix-time (util:to-unix-time now)) now))
|
||||
(let* ((x (util:ptr))
|
||||
|
@ -80,7 +82,14 @@
|
|||
(== (util:plist-add pl :b 1) '(:b 1 :a 0))
|
||||
(== pl '(:b 1 :a 0))))
|
||||
|
||||
(deftest test-record ()
|
||||
(deftest test-util-crypt ()
|
||||
(util:lgi (crypt:create-secret))
|
||||
)
|
||||
|
||||
(deftest test-util-iter ()
|
||||
)
|
||||
|
||||
(deftest test-shape()
|
||||
(let ((rec (make-instance 'shape:record :head '(:t1))))
|
||||
(== (shape:head rec) '(:t1 nil))
|
||||
(== (shape:head-value rec :taskid) :t1)
|
||||
|
|
21
testing.lisp
21
testing.lisp
|
@ -6,7 +6,7 @@
|
|||
(:use :common-lisp)
|
||||
(:export #:*test-suite*
|
||||
#:test-suite #:deftest #:show-result
|
||||
#:failure #:test #:== #:has-prefix
|
||||
#:failure #:check #:test #:== #:has-prefix
|
||||
#:test-path #:*current-system*))
|
||||
|
||||
(in-package :scopes/testing)
|
||||
|
@ -35,19 +35,18 @@
|
|||
(defun failure (fmt &rest vals)
|
||||
(push (apply #'format nil fmt vals) (errors *test-suite*)))
|
||||
|
||||
(defun == (have wanted)
|
||||
(let ((suite *test-suite*)
|
||||
(is-ok (equalp have wanted)))
|
||||
(push is-ok (car (result suite)))
|
||||
(defun check (fn fmt have wanted)
|
||||
(let ((is-ok (funcall fn have wanted)))
|
||||
(push is-ok (car (result *test-suite*)))
|
||||
(unless is-ok
|
||||
(failure "~s!=~s" have wanted))))
|
||||
(failure fmt have wanted))))
|
||||
|
||||
(defun == (have wanted)
|
||||
(check #'equalp "~s!=~s" have wanted))
|
||||
|
||||
(defun has-prefix (have wanted)
|
||||
(let ((suite *test-suite*)
|
||||
(is-ok (string= (str:prefix (list have wanted)) wanted)))
|
||||
(push is-ok (car (result suite)))
|
||||
(unless is-ok
|
||||
(failure "~s has not prefix ~s" have wanted))))
|
||||
(check #'(lambda (h w) (string= (str:prefix (list h w)) w))
|
||||
"~s has not prefix ~s" have wanted))
|
||||
|
||||
(defmacro deftest (name args &body body)
|
||||
`(defun ,name ,args
|
||||
|
|
9
util/iter.lisp
Normal file
9
util/iter.lisp
Normal file
|
@ -0,0 +1,9 @@
|
|||
;;;; cl-scopes/util/iter
|
||||
|
||||
;;;; iterators, queues, and other sequentially accessible stuff
|
||||
;;;; producing items (objects) like: numbers, strings, symbols, lists, ...
|
||||
|
||||
(defpackage :scopes/util/iter
|
||||
(:use :common-lisp))
|
||||
|
||||
(in-package :scopes/util/iter)
|
Loading…
Add table
Reference in a new issue