Skip to content

Commit

Permalink
converted to lisp-unit2 re ADWolf:#1201
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbysmith007 committed Jan 1, 2014
1 parent b71bd27 commit 50eb411
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
4 changes: 2 additions & 2 deletions clsql-helper.asd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
:serial t
:components ((:file "clsql")
(:file "iterate-clauses"))))
:depends-on (:clsql-helper :lisp-unit))
:depends-on (:clsql-helper :lisp-unit2))

(defmethod asdf:perform ((o asdf:test-op) (c (eql (find-system :clsql-helper))))
(asdf:load-system :clsql-helper-test)
Expand All @@ -45,7 +45,7 @@
(pushnew :clsql-sqlite3 *features*))

(let ((*package* (find-package :clsql-helper-test)))
(eval (read-from-string "(run-tests :all)"))))
(eval (read-from-string "(run-tests)"))))

;; Copyright (c) 2011 Russ Tyndall , Acceleration.net http://www.acceleration.net

Expand Down
29 changes: 19 additions & 10 deletions tests/clsql.lisp
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
(defpackage :clsql-helper-test
(:use :cl :clsql-helper :lisp-unit :iter))
(:use :cl :clsql-helper :lisp-unit2 :iter)
(:shadow :run-tests))

(in-package :clsql-helper-test)
(cl-interpol:enable-interpol-syntax)
(clsql-sys:file-enable-sql-reader-syntax)

(define-test test-clsql-parse-and-print
(defun run-tests (&key suites tests)
(let* ((*package* (find-package :cl-mediawiki-test)))
(lisp-unit2:run-tests
:tests tests
:tags suites
:name :cl-mediawiki
:run-contexts #'lisp-unit2:with-summary-context)))

(define-test test-clsql-parse-and-print (:tags '(dates))
(let ((dates
`(("7/1/2005"
"07/01/2005 00:00:00" "7/1/2005" "2005-07-01" "2005-07-01 00:00:00")
Expand Down Expand Up @@ -56,7 +65,7 @@
(assert-equal c-iso-time iso-time d)
(assert-equal c-iso-date iso-date d))))

(define-test test-expression-building
(define-test test-expression-building (:tags '(expressions))
(assert-false (clsql-ands ()))
(assert-false (clsql-and () () ()))
(assert-false (clsql-and))
Expand All @@ -82,7 +91,7 @@
exp
str() ())))))

(define-test test-db-string
(define-test test-db-string (:tags '(expressions))
(assert-equal "'a sql ''string'' quoting test'"
(db-string "a sql 'string' quoting test")))

Expand All @@ -108,7 +117,7 @@
(:not-null) :type integer :initarg :id))
(:default-initargs :VIEW-TABLE "MyTable"))

(define-test test-pkey-stuff
(define-test test-pkey-stuff (:tags '(keys expressions))
(assert-equal
'(id)
(primary-key-slot-names (make-instance 'pkey-test-1)))
Expand Down Expand Up @@ -137,7 +146,7 @@
(clsql:sql (primary-key-where-clauses pk2)))
))

(define-test test-db-eql
(define-test test-db-eql (:tags '(keys expressions))
(let ((pk1 (make-instance 'pkey-test-1 :name "russ" :id 1))
(pk1.2 (make-instance 'pkey-test-1 :name "Bobby" :id 1))
(pk1.3 (make-instance 'pkey-test-1 :name "Bobby" :id 2))
Expand All @@ -149,7 +158,7 @@
(assert-false (db-eql pk1 pk1.3))
(assert-false (db-eql pk2 pk1))))

(define-test table-and-column-expressions
(define-test table-and-column-expressions (:tags '(expressions))
(assert-equal "\"foo\"" (column-name-string "foo"))
(assert-equal "FOO" (column-name-string 'foo))
(assert-equal "\"foo\"" (table-name-string "foo"))
Expand All @@ -173,7 +182,7 @@
(defun sql-log (str &rest args)
(apply #'format *log* str args))

(define-test log-test
(define-test log-test (:tags '(sqlite3))
(assert-true
(search
"
Expand All @@ -187,7 +196,7 @@
:test #'string-equal))
))

(define-test clsql-date/times->utime
(define-test clsql-date/times->utime (:tags '(dates))
(let ((utime 3542038020))
(multiple-value-bind (sec min hr date month year day daylight-savings-p zone)
(decode-universal-time utime)
Expand All @@ -204,7 +213,7 @@
(clsql-sys:utime->time utime) nil)))))

;; verify that whitespace doesn't matter when generating a hash for migrations
(define-test migrations/whitespace-in-hash
(define-test migrations/whitespace-in-hash (:tags '(migrations))
(let ((hash (clsql-helper::%sql-hash "A B C")))
(assert-equal hash (clsql-helper::%sql-hash "A B C") "more spaces")
(assert-equal hash (clsql-helper::%sql-hash "A
Expand Down
18 changes: 9 additions & 9 deletions tests/iterate-clauses.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
test-iterate-clauses-date-5 test-iterate-clauses-date-6
test-iterate-clauses-negative-date test-iterate-clauses-negative-date-2))

(define-test test-iterate-clauses-date
(define-test test-iterate-clauses-date (:tags '(iterate-clauses))
(assert-equalp
'("4/1/2012" NIL "4/3/2012" "4/1/2012" "4/5/2012" "4/3/2012")
(iter
Expand All @@ -19,7 +19,7 @@
(collect (print-nullable-date y))
)))

(define-test test-iterate-clauses-date-2
(define-test test-iterate-clauses-date-2 (:tags '(iterate-clauses))
(assert-equalp
'("4/1/2012" NIL "4/3/2012" "4/1/2012" "4/5/2012" "4/3/2012")
(iter
Expand All @@ -30,7 +30,7 @@
(collect (print-nullable-date y))
)))

(define-test test-iterate-clauses-date-3
(define-test test-iterate-clauses-date-3 (:tags '(iterate-clauses))
(assert-equalp
'("4/1/2012" NIL "4/3/2012" "4/1/2012" )
(iter
Expand All @@ -41,7 +41,7 @@
)
:date-to))

(define-test test-iterate-clauses-date-4
(define-test test-iterate-clauses-date-4 (:tags '(iterate-clauses))
(assert-equalp
'("4/1/2012" NIL "4/3/2012" "4/1/2012" )
(iter
Expand All @@ -51,7 +51,7 @@
(collect (print-nullable-date y))
)
:datetime-to))
(define-test test-iterate-clauses-date-5
(define-test test-iterate-clauses-date-5 (:tags '(iterate-clauses))
(assert-equalp
'("4/1/2012" NIL "4/3/2012" "4/1/2012" "4/5/2012" "4/3/2012")
(iter
Expand All @@ -62,7 +62,7 @@
)
:date-thru))

(define-test test-iterate-clauses-date-6
(define-test test-iterate-clauses-date-6 (:tags '(iterate-clauses))
(assert-equalp
'("4/1/2012" NIL "4/3/2012" "4/1/2012" "4/5/2012" "4/3/2012")
(iter
Expand All @@ -73,23 +73,23 @@
)
:datetime-thru))

(define-test test-iterate-clauses-negative-date
(define-test test-iterate-clauses-negative-date (:tags '(iterate-clauses))
(assert-equalp
'("4/1/2012" "3/31/2012" "3/30/2012" "3/29/2012" "3/28/2012")
(iter
(for d from-datetime "4/1/2012" thru "3/28/2012" by :negative-day)
(collect (print-nullable-date d)))
:datetime-thru-negative-day))

(define-test test-iterate-clauses-negative-date-2
(define-test test-iterate-clauses-negative-date-2 (:tags '(iterate-clauses))
(assert-equalp
'("4/1/2012" "3/1/2012" "2/1/2012")
(iter
(for d from-datetime "4/1/2012" to "1/1/2012" by :negative-month)
(collect (print-nullable-date d)))
:datetime-thru-negative-month))

(define-test test-iterate-clauses-negative-date-3
(define-test test-iterate-clauses-negative-date-3 (:tags '(iterate-clauses))
(assert-equalp
'("4/1/2012" "3/1/2012" "2/1/2012")
(iter
Expand Down
3 changes: 1 addition & 2 deletions tests/set-slot-value-using-class.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
(clsql-sys:varchar 4) :initarg salt))
(base-table users))

(define-test test-slot-value-coersion
(define-test test-slot-value-coersion (:tags '(slot-coercer))
(let ((u (make-instance 'user)))
(setf (first-name u) "First" )
(assert-true (stringp (first-name u)))
Expand Down Expand Up @@ -83,4 +83,3 @@
(assert-true (typep (amount u) 'double-float) (amount u))
))

;(run-tests)

0 comments on commit 50eb411

Please sign in to comment.