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"))
|
:env-path (t:test-path ".test.env"))
|
||||||
|
|
||||||
(config:add :logger :class 'logging:config
|
(config:add :logger :class 'logging:config
|
||||||
:loglevel :info
|
:loglevel :debug
|
||||||
:logfile (t:test-path "scopes-test.log" "log")
|
:logfile (t:test-path "scopes-test.log" "log")
|
||||||
:console nil)
|
:console nil)
|
||||||
|
|
||||||
|
|
|
@ -46,5 +46,5 @@
|
||||||
(deftest test-client (client)
|
(deftest test-client (client)
|
||||||
(let ((msg (message:create
|
(let ((msg (message:create
|
||||||
'(:auth :login)
|
'(:auth :login)
|
||||||
:data '(:name "admin" :password "sc0pes"))))
|
:data '(:org "system" :name "admin" :password "sc0pes"))))
|
||||||
(client:send-message client msg)))
|
(client:send-message client msg)))
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:local-nicknames (:auth :scopes-auth)
|
(:local-nicknames (:auth :scopes-auth)
|
||||||
(:config :scopes/config)
|
(:config :scopes/config)
|
||||||
(:core :scopes/core))
|
(:core :scopes/core)
|
||||||
|
(:util :scopes/util))
|
||||||
(:export #:login))
|
(:export #:login))
|
||||||
|
|
||||||
(in-package :scopes-auth/web)
|
(in-package :scopes-auth/web)
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
(:file "shape/shape")
|
(:file "shape/shape")
|
||||||
(:file "util/util")
|
(:file "util/util")
|
||||||
(:file "util/crypt" :depends-on ("util/util"))
|
(:file "util/crypt" :depends-on ("util/util"))
|
||||||
|
(:file "util/iter")
|
||||||
(:file "testing" :depends-on ("util/util")))
|
(:file "testing" :depends-on ("util/util")))
|
||||||
:long-description "scopes/core: The core packages of the scopes project."
|
:long-description "scopes/core: The core packages of the scopes project."
|
||||||
:in-order-to ((test-op (test-op "scopes-core/test"))))
|
:in-order-to ((test-op (test-op "scopes-core/test"))))
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
(:config :scopes/config)
|
(:config :scopes/config)
|
||||||
(:core :scopes/core)
|
(:core :scopes/core)
|
||||||
(:crypt :scopes/util/crypt)
|
(:crypt :scopes/util/crypt)
|
||||||
|
(:iter :scopes/util/iter)
|
||||||
(:logging :scopes/logging)
|
(:logging :scopes/logging)
|
||||||
(:message :scopes/core/message)
|
(:message :scopes/core/message)
|
||||||
(:shape :scopes/shape)
|
(:shape :scopes/shape)
|
||||||
|
@ -55,7 +56,9 @@
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
(test-util)
|
(test-util)
|
||||||
(test-record)
|
(test-util-crypt)
|
||||||
|
(test-util-iter)
|
||||||
|
(test-shape)
|
||||||
(core:setup-services)
|
(core:setup-services)
|
||||||
(setf (receiver t:*test-suite*) (core:find-service :test-receiver))
|
(setf (receiver t:*test-suite*) (core:find-service :test-receiver))
|
||||||
(test-send))
|
(test-send))
|
||||||
|
@ -64,7 +67,6 @@
|
||||||
(t:show-result))))
|
(t:show-result))))
|
||||||
|
|
||||||
(deftest test-util ()
|
(deftest test-util ()
|
||||||
(util:lgi (crypt:create-secret))
|
|
||||||
(let ((now (get-universal-time)))
|
(let ((now (get-universal-time)))
|
||||||
(== (util:from-unix-time (util:to-unix-time now)) now))
|
(== (util:from-unix-time (util:to-unix-time now)) now))
|
||||||
(let* ((x (util:ptr))
|
(let* ((x (util:ptr))
|
||||||
|
@ -80,7 +82,14 @@
|
||||||
(== (util:plist-add pl :b 1) '(:b 1 :a 0))
|
(== (util:plist-add pl :b 1) '(:b 1 :a 0))
|
||||||
(== pl '(: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))))
|
(let ((rec (make-instance 'shape:record :head '(:t1))))
|
||||||
(== (shape:head rec) '(:t1 nil))
|
(== (shape:head rec) '(:t1 nil))
|
||||||
(== (shape:head-value rec :taskid) :t1)
|
(== (shape:head-value rec :taskid) :t1)
|
||||||
|
|
21
testing.lisp
21
testing.lisp
|
@ -6,7 +6,7 @@
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:export #:*test-suite*
|
(:export #:*test-suite*
|
||||||
#:test-suite #:deftest #:show-result
|
#:test-suite #:deftest #:show-result
|
||||||
#:failure #:test #:== #:has-prefix
|
#:failure #:check #:test #:== #:has-prefix
|
||||||
#:test-path #:*current-system*))
|
#:test-path #:*current-system*))
|
||||||
|
|
||||||
(in-package :scopes/testing)
|
(in-package :scopes/testing)
|
||||||
|
@ -35,19 +35,18 @@
|
||||||
(defun failure (fmt &rest vals)
|
(defun failure (fmt &rest vals)
|
||||||
(push (apply #'format nil fmt vals) (errors *test-suite*)))
|
(push (apply #'format nil fmt vals) (errors *test-suite*)))
|
||||||
|
|
||||||
(defun == (have wanted)
|
(defun check (fn fmt have wanted)
|
||||||
(let ((suite *test-suite*)
|
(let ((is-ok (funcall fn have wanted)))
|
||||||
(is-ok (equalp have wanted)))
|
(push is-ok (car (result *test-suite*)))
|
||||||
(push is-ok (car (result suite)))
|
|
||||||
(unless is-ok
|
(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)
|
(defun has-prefix (have wanted)
|
||||||
(let ((suite *test-suite*)
|
(check #'(lambda (h w) (string= (str:prefix (list h w)) w))
|
||||||
(is-ok (string= (str:prefix (list have wanted)) wanted)))
|
"~s has not prefix ~s" have wanted))
|
||||||
(push is-ok (car (result suite)))
|
|
||||||
(unless is-ok
|
|
||||||
(failure "~s has not prefix ~s" have wanted))))
|
|
||||||
|
|
||||||
(defmacro deftest (name args &body body)
|
(defmacro deftest (name args &body body)
|
||||||
`(defun ,name ,args
|
`(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