1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: test-connection.lisp
6 ;;;; Purpose: Tests for CLSQL database connections
7 ;;;; Authors: Marcus Pearce and Kevin M. Rosenberg
8 ;;;; Created: March 2004
10 ;;;; This file is part of CLSQL.
12 ;;;; CLSQL users are granted the rights to distribute and use this software
13 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
14 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
15 ;;;; *************************************************************************
17 (in-package #:clsql-tests)
22 (deftest :connection/1
23 (let ((database (clsql:find-database
24 (clsql:database-name clsql:*default-database*)
25 :db-type (clsql-sys:database-type clsql:*default-database*))))
26 (eql (clsql-sys:database-type database) *test-database-type*))
29 (deftest :connection/2
30 (clsql-sys::string-to-list-connection-spec
31 "localhost/dbname/user/passwd")
32 ("localhost" "dbname" "user" "passwd"))
34 (deftest :connection/3
35 (clsql-sys::string-to-list-connection-spec
36 "dbname/user@hostname")
37 ("hostname" "dbname" "user"))
39 (deftest :connection/execute-command
40 ;;check that we can issue basic commands.
42 (clsql-sys:execute-command "CREATE TABLE DUMMY (foo integer)")
43 (clsql-sys:execute-command "DROP TABLE DUMMY"))
46 (deftest :connection/query
47 ;;check that we can do a basic query
48 (first (clsql:query "SELECT 1" :flatp t :field-names nil))
51 (deftest :connection/query-command
52 ;;queries that are commands (no result set) shouldn't cause breakage
54 (clsql-sys:query "CREATE TABLE DUMMY (foo integer)")
55 (clsql-sys:query "DROP TABLE DUMMY"))
58 (deftest :connection/pool/procedure-mysql
61 (clsql-sys:disconnect)
62 (test-connect :pool t)
63 (clsql-sys:execute-command
64 "CREATE PROCEDURE prTest () BEGIN SELECT 1 \"a\",2 \"b\",3 \"c\" ,4 \"d\" UNION SELECT 5,6,7,8; END;")
65 (clsql-sys:disconnect)
66 (test-connect :pool t)
67 (let ((p0 (clsql-sys:query "CALL prTest();" :flatp t)))
68 (clsql-sys:disconnect)
69 (test-connect :pool t)
70 (let ((p1 (clsql-sys:query "CALL prTest();" :flatp t)))
71 (clsql-sys:disconnect)
72 (test-connect :pool t)
75 (clsql-sys:execute-command "DROP PROCEDURE prTest;"))
78 ((1 2 3 4) (5 6 7 8)))