Scenario.
parent
7821a1a819
commit
cfe7a87bfa
|
@ -0,0 +1,33 @@
|
|||
(load "./dodb.cl")
|
||||
|
||||
;
|
||||
; TEST SCENARIO
|
||||
;
|
||||
|
||||
(defstruct vehicle name color)
|
||||
|
||||
;(defparameter cars (db/new "vehicle" "./storage/cars/"))
|
||||
; to launch the tests in RAM
|
||||
(defparameter cars (db/new "vehicle" "/tmp/storage/cars/"))
|
||||
|
||||
(db/add cars (make-vehicle :name "Corvet" :color "Red"))
|
||||
(db/add cars (make-vehicle :name "Ferrari" :color "Red"))
|
||||
(db/add cars (make-vehicle :name "Deudeuch" :color "Beige"))
|
||||
(db/add cars (make-vehicle :name "BMW" :color "Blue"))
|
||||
(db/add cars (make-vehicle :name "Suzuki Wagon" :color "Blue"))
|
||||
|
||||
(db/new-index cars "name")
|
||||
(db/new-partition cars "color")
|
||||
|
||||
|
||||
(format t "~&~S~&" cars)
|
||||
|
||||
(format t "db/get-by-index ~S~&" (db/get-by-index cars "name" "Corvet"))
|
||||
(format t "db/get-by-partition red cars:~&")
|
||||
|
||||
(loop for car in (db/get-by-partition cars "color" "Red")
|
||||
do (format t "- ~S~&" car))
|
||||
|
||||
(let ((suzuki (db/get-by-index cars "name" "Suzuki Wagon")))
|
||||
(setf (vehicle-color (gethash suzuki (db-data cars))) "White")
|
||||
(db/update cars suzuki))
|
Loading…
Reference in New Issue