X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=test-clsql.cl;h=78f83dec239c802cce1349da682f79fa5c7c198d;hb=68a2a2bd6a380a61dce06a0510dab3441400d795;hp=cbc5e928ef49e5e6225e2723226e649f86de4e42;hpb=421ef23a5a01534ac4c4d7594d182023ed31b376;p=clsql.git diff --git a/test-clsql.cl b/test-clsql.cl index cbc5e92..78f83de 100644 --- a/test-clsql.cl +++ b/test-clsql.cl @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Mar 2002 ;;;; -;;;; $Id: test-clsql.cl,v 1.5 2002/03/25 06:07:06 kevin Exp $ +;;;; $Id: test-clsql.cl,v 1.7 2002/03/25 23:22:07 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -25,13 +25,15 @@ :defaults *load-truename*)) (defparameter *config* nil) -(defun do-test () - (if (probe-file *config-pathname*) - (with-open-file (stream *config-pathname* :direction :input) - (setq *config* (read stream)) - (test-automated *config*)) - (test-interactive))) - +(defun do-test (&optional (interactive nil)) + (if interactive + (test-interactive) + (if (probe-file *config-pathname*) + (with-open-file (stream *config-pathname* :direction :input) + (setq *config* (read stream)) + (test-automated *config*)) + (test-interactive)))) + (defun test-interactive () (do ((done nil)) (done) @@ -52,6 +54,20 @@ ) +(defun create-test-table (db) + (ignore-errors + (clsql:execute-command + "DROP TABLE test_clsql" :database db)) + (clsql:execute-command + "CREATE TABLE test_clsql (i integer, sqrt float, sqrt_str CHAR(20))" :database db) + (dotimes (i 10) + (clsql:execute-command + (format nil "INSERT INTO test_clsql VALUES (~d,~d,'~a')" + i (sqrt i) (format nil "~d" (sqrt i))) + :database db))) + +(defun drop-test-table (db) + (clsql:execute-command "DROP TABLE test_clsql")) (defun clsql-test-table (spec type) (when (eq type :mysql) @@ -59,20 +75,14 @@ (let ((db (clsql:connect spec :database-type type :if-exists :new))) (unwind-protect (progn - (ignore-errors - (clsql:execute-command - "DROP TABLE test_clsql" :database db)) - (clsql:execute-command - "CREATE TABLE test_clsql (i integer, sqrt float, sqrt_str CHAR(20))" :database db) - (dotimes (i 10) - (clsql:execute-command - (format nil "INSERT INTO test_clsql VALUES (~d,~d,'~a')" - i (sqrt i) (format nil "~d" (sqrt i))) - :database db)) + (create-test-table db) + (pprint (clsql:query "select * from test_clsql" + :database db + :field-types :auto)) (pprint (clsql:map-query 'vector #'list "select * from test_clsql" :database db - :field-types '(:int :double t))) - (clsql:execute-command "DROP TABLE test_clsql")) + :field-types :auto)) ;;'(:int :double t))) + (drop-test-table db)) (clsql:disconnect :database db))) )