Skip to content

Commit

Permalink
convered orphan sql-ident-table test function to use RT and run with
Browse files Browse the repository at this point in the history
the rest of the syntax tests (and fail)

Had to fix some package references, and uses backquote to splice
together the a decent deftest form without being overly verbose. Also
used clsql:sql instead of calling output-sql directly.

Currently fails by not preserving case when using a symbol like '|foo|
as the table name, we're getting "FOO" not "foo".
  • Loading branch information
ryepup committed Mar 27, 2012
1 parent 85508ad commit b0b0c67
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions tests/test-syntax.lisp
Expand Up @@ -445,18 +445,21 @@


)) ))


(defun test-output-sql/sql-ident-table () (let ((tests '(((:foo) "FOO")
(let ((tests `((,(make-instance 'sql-ident-table :name :foo) "FOO") ((:foo-bar) "FOO_BAR")
(,(make-instance 'sql-ident-table :name :foo-bar) "FOO_BAR") (("foo") "\"foo\"")
(,(make-instance 'sql-ident-table :name "foo") "\"foo\"") (('|foo bar|) "\"foo bar\"")
(,(make-instance 'sql-ident-table :name '|foo bar|) "\"foo bar\"") ((:foo :table-alias :bar) "FOO BAR" )
(,(make-instance 'sql-ident-table :name :foo :table-alias :bar) "FOO BAR" ) ((:foo_bar :table-alias :bar-bast) "FOO_BAR BAR_BAST")
(,(make-instance 'sql-ident-table :name :foo_bar :table-alias :bar-bast) "FOO_BAR BAR_BAST") (("foo" :table-alias "Bar") "\"foo\" \"Bar\"")
(,(make-instance 'sql-ident-table :name "foo" :table-alias "Bar") "\"foo\" \"Bar\"") (('|foo bar| :table-alias :bast) "\"foo bar\" BAST"))))
(,(make-instance 'sql-ident-table :name '|foo bar| :table-alias :bast) "\"foo bar\" BAST"))))
(loop for (test expected-result) in tests (push
for test-out = (with-output-to-string (*sql-stream*) (output-sql test nil)) `(deftest :syntax/sql-ident-table
do (assert (string-equal test-out expected-result) (values ,@(mapcar
(test test-out expected-result) #'(lambda (args)
"Test:~s didnt match ~S" `(clsql:sql (make-instance 'clsql-sys:sql-ident-table
test-out expected-result)))) :name ,@args)))
(mapcar #'first tests)))
,@(mapcar #'second tests))
*rt-syntax*))

0 comments on commit b0b0c67

Please sign in to comment.