Adding new connection tests that are the simplest query/command against a database...
[clsql.git] / tests / test-connection.lisp
index 7680917bb103523cc05bbf1dbf743f60bb80069a..25c8b733c38f76b6f2d7162d5659071c0b4be7ba 100644 (file)
@@ -1,24 +1,58 @@
 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
 ;;;; ======================================================================
 ;;;; File:    test-connection.lisp
-;;;; Author:  Marcus Pearce <m.t.pearce@city.ac.uk>
+;;;; Authors: Marcus Pearce <m.t.pearce@city.ac.uk>, Kevin Rosenberg
 ;;;; Created: 30/03/2004
-;;;; Updated: <04/04/2004 11:53:49 marcusp>
-;;;; ======================================================================
+;;;; Updated: $Id$
 ;;;;
-;;;; Description ==========================================================
-;;;; ======================================================================
+;;;; Tests for CLSQL database connections.
 ;;;;
-;;;; Tests for CLSQL-USQL database connections. 
+;;;; This file is part of CLSQL.
 ;;;;
+;;;; CLSQL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
 ;;;; ======================================================================
 
-(in-package :clsql-usql-tests)
+(in-package #:clsql-tests)
 
+(setq *rt-connection*
+      '(
 
 (deftest :connection/1
-    (let ((database (usql:find-database
-                     (usql:database-name usql:*default-database*)
-                     :db-type (usql:database-type usql:*default-database*))))
-      (eql (usql:database-type database) *test-database-type*))
+    (let ((database (clsql:find-database
+                     (clsql:database-name clsql:*default-database*)
+                     :db-type (clsql-sys:database-type clsql:*default-database*))))
+      (eql (clsql-sys:database-type database) *test-database-type*))
   t)
+
+(deftest :connection/2
+    (clsql-sys::string-to-list-connection-spec
+     "localhost/dbname/user/passwd")
+  ("localhost" "dbname" "user" "passwd"))
+
+(deftest :connection/3
+    (clsql-sys::string-to-list-connection-spec
+     "dbname/user@hostname")
+  ("hostname" "dbname" "user"))
+
+(deftest :connection/execute-command
+    ;;check that we can issue basic commands.
+    (values
+      (clsql-sys:execute-command "CREATE TABLE DUMMY (foo integer)")
+      (clsql-sys:execute-command "DROP TABLE DUMMY"))
+  nil nil)
+
+(deftest :connection/query
+    ;;check that we can do a basic query
+    (first (clsql:query "SELECT 1" :flatp t :field-names nil))
+  1)
+
+(deftest :connection/query-command
+    ;;queries that are commands (no result set) shouldn't cause breakage
+    (values
+      (clsql-sys:query "CREATE TABLE DUMMY (foo integer)")
+      (clsql-sys:query "DROP TABLE DUMMY"))
+  nil nil)
+
+))