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)
|
(defun connect-sqlite (params config)
|
||||||
(declare (ignorable params))
|
(declare (ignorable params))
|
||||||
(print config)
|
(apply #'dbi:connect-cached :sqlite3 (getf config :connect-args)))
|
||||||
(apply #'dbi:connect-cached (cons :sqlite3 (getf config :connect-args))))
|
|
||||||
|
|
||||||
(defun connect-postgres (params config)
|
(defun connect-postgres (params config)
|
||||||
(declare (ignorable params))
|
(declare (ignorable params))
|
||||||
(apply #'dbi:connect (cons :postgres (getf config :connect-args))))
|
(apply #'dbi:connect-cached :postgres (getf config :connect-args)))
|
||||||
|
|
||||||
(defvar *db-params*
|
(defvar *db-params*
|
||||||
'(:sqlite3 (:connect connect-sqlite
|
'(: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)
|
(:local-nicknames (:storage :scopes/storage)
|
||||||
(:tracking :scopes/storage/tracking)
|
(:tracking :scopes/storage/tracking)
|
||||||
(:t :scopes/testing))
|
(:t :scopes/testing))
|
||||||
(:export #:*db-config-postgres* #:*db-config-sqlite*
|
(:export #:*db-config-test*
|
||||||
#:run #:run-all #:run-postgres #:run-sqlite)
|
#:run #:run-all #:run-postgres #:run-sqlite)
|
||||||
(:import-from :scopes/testing #:==))
|
(:import-from :scopes/testing #:==))
|
||||||
|
|
||||||
(in-package :scopes/test-storage)
|
(in-package :scopes/test-storage)
|
||||||
|
|
||||||
(defparameter *db-config-sqlite* nil)
|
(defparameter *db-config-test* nil)
|
||||||
(defparameter *db-config-postgres* nil)
|
|
||||||
(load "test/etc")
|
|
||||||
|
|
||||||
(defun run-all ()
|
(defun run-all ()
|
||||||
(run-sqlite)
|
(run-sqlite)
|
||||||
(run-postgres))
|
(run-postgres))
|
||||||
|
|
||||||
(defun run-sqlite ()
|
(defun run-sqlite ()
|
||||||
(let ((storage:*db-config* *db-config-sqlite*))
|
(load "test/config-sqlite")
|
||||||
|
(let ((storage:*db-config* *db-config-test*))
|
||||||
(run)))
|
(run)))
|
||||||
|
|
||||||
(defun run-postgres ()
|
(defun run-postgres ()
|
||||||
(let ((storage:*db-config* *db-config-postgres*))
|
(load "test/config-postgres")
|
||||||
|
(let ((storage:*db-config* *db-config-test*))
|
||||||
(run)))
|
(run)))
|
||||||
|
|
||||||
(defun run ()
|
(defun run ()
|
||||||
|
|
Loading…
Add table
Reference in a new issue