improve test set-up, load config when running test
This commit is contained in:
parent
3aacee896d
commit
3b36d4e54a
5 changed files with 34 additions and 31 deletions
|
@ -45,12 +45,11 @@
|
|||
|
||||
(defun connect-sqlite (params config)
|
||||
(declare (ignorable params))
|
||||
(print config)
|
||||
(apply #'dbi:connect-cached (cons :sqlite3 (getf config :connect-args))))
|
||||
(apply #'dbi:connect-cached :sqlite3 (getf config :connect-args)))
|
||||
|
||||
(defun connect-postgres (params config)
|
||||
(declare (ignorable params))
|
||||
(apply #'dbi:connect (cons :postgres (getf config :connect-args))))
|
||||
(apply #'dbi:connect-cached :postgres (getf config :connect-args)))
|
||||
|
||||
(defvar *db-params*
|
||||
'(:sqlite3 (:connect connect-sqlite
|
||||
|
|
15
test/config-postgres.lisp
Normal file
15
test/config-postgres.lisp
Normal file
|
@ -0,0 +1,15 @@
|
|||
;;; cl-scopes/test/config-postgres.lisp
|
||||
;;; use: `(load "test/...")` from package scopes/test-storage
|
||||
|
||||
(defparameter db-config-postgres
|
||||
'(:db-type :postgres
|
||||
:connect-args
|
||||
(:database-name "cltest"
|
||||
:host "localhost"
|
||||
:port 5432
|
||||
:username "testuser"
|
||||
:password "secret")
|
||||
:options
|
||||
(:schema "testing")))
|
||||
|
||||
(setf scopes/test-storage:*db-config-test* db-config-postgres)
|
11
test/config-sqlite.lisp
Normal file
11
test/config-sqlite.lisp
Normal file
|
@ -0,0 +1,11 @@
|
|||
;;; cl-scopes/test/config-sqlite.lisp
|
||||
;;; use: `(load "test/...")` from package scopes/test-storage
|
||||
|
||||
(defparameter db-config-sqlite
|
||||
'(:db-type :sqlite3
|
||||
:connect-args
|
||||
(:database-name "test/test.db")
|
||||
:options nil))
|
||||
|
||||
(setf scopes/test-storage:*db-config-test* db-config-sqlite)
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
;;; cl-scopes/test/etc.lisp
|
||||
;;; use: `(load "test/etc")` from package scopes/test-storage
|
||||
|
||||
(defparameter db-config-sqlite
|
||||
'(:db-type :sqlite3
|
||||
:connect-args
|
||||
(:database-name "test/test.db")
|
||||
:options nil))
|
||||
|
||||
(defparameter db-config-postgres
|
||||
'(:db-type :postgres
|
||||
:connect-args
|
||||
(:database-name "cltest"
|
||||
:host "localhost"
|
||||
:port 5432
|
||||
:username "testuser"
|
||||
:password "secret")
|
||||
:options
|
||||
(:schema "testing")))
|
||||
|
||||
(setf scopes/test-storage:*db-config-sqlite* db-config-sqlite)
|
||||
(setf scopes/test-storage:*db-config-postgres* db-config-postgres)
|
|
@ -7,26 +7,26 @@
|
|||
(:local-nicknames (:storage :scopes/storage)
|
||||
(:tracking :scopes/storage/tracking)
|
||||
(:t :scopes/testing))
|
||||
(:export #:*db-config-postgres* #:*db-config-sqlite*
|
||||
(:export #:*db-config-test*
|
||||
#:run #:run-all #:run-postgres #:run-sqlite)
|
||||
(:import-from :scopes/testing #:==))
|
||||
|
||||
(in-package :scopes/test-storage)
|
||||
|
||||
(defparameter *db-config-sqlite* nil)
|
||||
(defparameter *db-config-postgres* nil)
|
||||
(load "test/etc")
|
||||
(defparameter *db-config-test* nil)
|
||||
|
||||
(defun run-all ()
|
||||
(run-sqlite)
|
||||
(run-postgres))
|
||||
|
||||
(defun run-sqlite ()
|
||||
(let ((storage:*db-config* *db-config-sqlite*))
|
||||
(load "test/config-sqlite")
|
||||
(let ((storage:*db-config* *db-config-test*))
|
||||
(run)))
|
||||
|
||||
(defun run-postgres ()
|
||||
(let ((storage:*db-config* *db-config-postgres*))
|
||||
(load "test/config-postgres")
|
||||
(let ((storage:*db-config* *db-config-test*))
|
||||
(run)))
|
||||
|
||||
(defun run ()
|
||||
|
|
Loading…
Add table
Reference in a new issue