-(defun test-connect-to-database (db-type)
- (let ((spec (db-type-spec db-type (read-specs))))
- (when (db-backend-has-create/destroy-db? db-type)
- (ignore-errors (destroy-database spec :database-type db-type))
- (ignore-errors (create-database spec :database-type db-type)))
-
-
- (setf *test-database-type* db-type)
- (when (>= (length spec) 3)
- (setq *test-database-user* (third spec)))
-
- ;; Connect to the database
- (clsql:connect spec
- :database-type db-type
- :make-default t
- :if-exists :old))
+(defun test-connect-to-database (db-type spec)
+ (when (db-backend-has-create/destroy-db? db-type)
+ (ignore-errors (destroy-database spec :database-type db-type))
+ (ignore-errors (create-database spec :database-type db-type)))
+
+ (setf *test-database-type* db-type)
+ (when (>= (length spec) 3)
+ (setq *test-database-user* (third spec)))
+
+ ;; Connect to the database
+ (clsql:connect spec
+ :database-type db-type
+ :make-default t
+ :if-exists :old)
(setf *test-database-underlying-type*
- (clsql-sys:database-underlying-type *default-database*))
+ (clsql-sys:database-underlying-type *default-database*))
*default-database*)
:first-name "Vladamir"
:last-name "Putin"
:email "putin@soviet.org"))
-
+
+ ;; sleep to ensure birthdays are no longer at current time
+ (sleep 2)
+
;; Lenin manages everyone
(clsql:add-to-relation employee2 'manager employee1)
(clsql:add-to-relation employee3 'manager employee1)
(return-from run-tests :skipped))
(load-necessary-systems specs)
(dolist (db-type +all-db-types+)
- (unless (and (eq db-type :aodbc)
- (not (member :allegro cl:*features*)))
- (when (db-type-spec db-type specs)
- (do-tests-for-backend db-type))))
- (zerop *error-count*)))
+ (dolist (spec (db-type-spec db-type specs))
+ (do-tests-for-backend db-type spec))))
+ (zerop *error-count*))
(defun load-necessary-systems (specs)
(dolist (db-type +all-db-types+)
(when (db-type-spec db-type specs)
(db-type-ensure-system db-type))))
-(defun do-tests-for-backend (db-type)
- (test-connect-to-database db-type)
+(defun do-tests-for-backend (db-type spec)
+ (test-connect-to-database db-type spec)
(unwind-protect
(multiple-value-bind (test-forms skip-tests)
:type "config"))
(defvar +all-db-types+
- #-clisp '(:postgresql :postgresql-socket :sqlite :mysql :odbc :aodbc)
+ #-clisp '(:postgresql :postgresql-socket :sqlite :mysql :odbc
+ #+allegro :aodbc)
#+clisp '(:sqlite))
(defclass conn-specs ()
- ((aodbc-spec :accessor aodbc-spec :initform nil)
- (odbc-spec :accessor odbc-spec :initform nil)
- (mysql-spec :accessor mysql-spec :initform nil)
- (postgresql-spec :accessor postgresql-spec :initform nil)
- (postgresql-socket-spec :accessor postgresql-socket-spec :initform nil)
- (sqlite-spec :accessor sqlite-spec :initform nil))
+ ((aodbc :accessor aodbc-spec :initform nil)
+ (odbc :accessor odbc-spec :initform nil)
+ (mysql :accessor mysql-spec :initform nil)
+ (postgresql :accessor postgresql-spec :initform nil)
+ (postgresql-socket :accessor postgresql-socket-spec :initform nil)
+ (sqlite :accessor sqlite-spec :initform nil))
(:documentation "Connection specs for CLSQL testing"))
(defun read-specs (&optional (path *config-pathname*))
(if (probe-file path)
(with-open-file (stream path :direction :input)
- (let ((config (read stream))
- (specs (make-instance 'conn-specs)))
- (dolist (db-type +all-db-types+)
- (setf (slot-value specs (spec-fn db-type))
- (cadr (assoc db-type config))))
- specs))
+ (let ((specs (make-instance 'conn-specs)))
+ (dolist (spec (read stream) specs)
+ (push (second spec)
+ (slot-value specs (intern (symbol-name (first spec))
+ (find-package '#:clsql-tests)))))))
(progn
(warn "CLSQL test config file ~S not found" path)
nil)))