;;; cl-scopes/test/test-storage ;;;; testing facility for scopes/storage (defpackage :scopes/test-storage (:use :common-lisp) (:local-nicknames (:config :scopes/config) (:core :scopes/core) (:storage :scopes/storage) (:tracking :scopes/storage/tracking) (:t :scopes/testing)) (:export #:*db-config-test* #:run #:run-all #:run-postgres #:run-sqlite) (:import-from :scopes/testing #:deftest #:==)) (in-package :scopes/test-storage) (defun run-all () (run-sqlite) (run-postgres)) (defun run-sqlite () (load (t:test-path "config-sqlite")) (let ((t:*test-suite* (t:test-suite "sqlite"))) (run))) (defun run-postgres () (load (t:test-path "config-postgres")) (let ((t:*test-suite* (t:test-suite "postgres"))) (run))) (defun run () (core:setup-services) (let* ((ctx (core:find-service :storage)) (cfg (core:config ctx))) (test-track ctx) (t:show-result))) (deftest test-track (ctx) (let ((st (storage:storage ctx)) (data (make-hash-table)) cont tr tr2) (setf cont (make-instance 'tracking:container :storage st)) (defparameter cl-user::*cont cont) (storage:drop-table st :tracks) (tracking:create-table cont) (setf tr (tracking:make-item cont "t01" "john")) (== (tracking:head tr) '("t01" "john")) (== (tracking:head-plist tr) '(:username "john" :taskid "t01")) (== (tracking:data tr) nil) (setf (gethash :desc data) "scopes/storage: queries") (setf (tracking:data tr) data) (tracking:insert tr) (== (tracking:trackid tr) 1) (setf tr2 (tracking:get-track cont 1)) (== (tracking:head tr2) '("t01" "john")) (== (gethash :desc (tracking:data tr2)) "scopes/storage: queries") ))