Changeset 206 for branches/new-datamodel/src/unit_tests
- Timestamp:
- 02/24/10 19:59:58 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/new-datamodel/src/unit_tests/datamodel_test.lisp ¶
r205 r206 24 24 :test-SubjectLocatorC 25 25 :test-TopicIdentificationC 26 :test-get-item-by-id)) 26 :test-get-item-by-id 27 :test-get-item-by-item-identifier 28 :test-get-item-by-locator 29 :test-get-item-by-psi)) 27 30 28 31 … … 364 367 365 368 369 (test test-get-item-by-item-identifier () 370 "Tests the function test-get-item-by-id." 371 (with-fixture with-empty-db (*db-dir*) 372 (let ((ii-1 (make-instance 'ItemIdentifierC 373 :uri "ii-1")) 374 (ii-2 (make-instance 'ItemIdentifierC 375 :uri "ii-2")) 376 (ii-3-1 (make-instance 'ItemIdentifierC 377 :uri "ii-3")) 378 (ii-3-2 (make-instance 'ItemIdentifierC 379 :uri "ii-3")) 380 (top-1 (make-instance 'TopicC)) 381 (top-2 (make-instance 'TopicC)) 382 (top-3 (make-instance 'TopicC)) 383 (revision 100) 384 (revision-2 200)) 385 (setf d:*TM-REVISION* revision) 386 (is-false (get-item-by-id "any-ii-id")) 387 (signals error (is-false (get-item-by-item-identifier 388 "any-ii-id" :error-if-nil t))) 389 (signals error (is-false (get-item-by-item-identifier 390 "any-ii-id" :error-if-nil t))) 391 (is-false (get-item-by-item-identifier "any-ii-id")) 392 (add-item-identifier top-1 ii-3-1 :revision revision) 393 (add-item-identifier top-1 ii-3-2 :revision revision) 394 (signals duplicate-identifier-error 395 (get-item-by-item-identifier "ii-3" :revision revision)) 396 (add-item-identifier top-2 ii-1) 397 (add-item-identifier top-2 ii-2 :revision revision-2) 398 (is (eql top-2 (get-item-by-item-identifier "ii-1"))) 399 (is (eql top-2 (get-item-by-item-identifier "ii-2"))) 400 (is (eql top-2 (get-item-by-item-identifier "ii-1" :revision 500))) 401 (is-false (get-item-by-item-identifier "ii-2" :revision revision)) 402 (delete-item-identifier top-2 ii-1 :revision revision-2) 403 (is-false (get-item-by-item-identifier "ii-1")) 404 (is (eql top-2 (get-item-by-item-identifier "ii-1" :revision revision))) 405 (add-item-identifier top-3 ii-1 :revision revision-2) 406 (is (eql top-2 (get-item-by-item-identifier "ii-1" :revision revision))) 407 (d::add-to-version-history top-3 :start-revision revision-2) 408 (is (eql top-3 (get-item-by-item-identifier "ii-1")))))) 409 410 411 (test test-get-item-by-locator () 412 "Tests the function test-get-item-by-id." 413 (with-fixture with-empty-db (*db-dir*) 414 (let ((sl-1 (make-instance 'SubjectLocatorC 415 :uri "sl-1")) 416 (sl-2 (make-instance 'SubjectLocatorC 417 :uri "sl-2")) 418 (sl-3-1 (make-instance 'SubjectLocatorC 419 :uri "sl-3")) 420 (sl-3-2 (make-instance 'SubjectLocatorC 421 :uri "sl-3")) 422 (top-1 (make-instance 'TopicC)) 423 (top-2 (make-instance 'TopicC)) 424 (top-3 (make-instance 'TopicC)) 425 (revision 100) 426 (revision-2 200)) 427 (setf d:*TM-REVISION* revision) 428 (is-false (get-item-by-id "any-sl-id")) 429 (signals error (is-false (get-item-by-locator 430 "any-sl-id" :error-if-nil t))) 431 (signals error (is-false (get-item-by-locator 432 "any-sl-id" :error-if-nil t))) 433 (is-false (get-item-by-locator "any-sl-id")) 434 (add-locator top-1 sl-3-1 :revision revision) 435 (add-locator top-1 sl-3-2 :revision revision) 436 (signals duplicate-identifier-error 437 (get-item-by-locator "sl-3" :revision revision)) 438 (add-locator top-2 sl-1) 439 (add-locator top-2 sl-2 :revision revision-2) 440 (is (eql top-2 (get-item-by-locator "sl-1"))) 441 (is (eql top-2 (get-item-by-locator "sl-2"))) 442 (is (eql top-2 (get-item-by-locator "sl-1" :revision 500))) 443 (is-false (get-item-by-locator "sl-2" :revision revision)) 444 (delete-locator top-2 sl-1 :revision revision-2) 445 (is-false (get-item-by-locator "sl-1")) 446 (is (eql top-2 (get-item-by-locator "sl-1" :revision revision))) 447 (add-locator top-3 sl-1 :revision revision-2) 448 (is (eql top-2 (get-item-by-locator "sl-1" :revision revision))) 449 (d::add-to-version-history top-3 :start-revision revision-2) 450 (is (eql top-3 (get-item-by-locator "sl-1")))))) 451 452 453 (test test-get-item-by-psi () 454 "Tests the function test-get-item-by-id." 455 (with-fixture with-empty-db (*db-dir*) 456 (let ((psi-1 (make-instance 'PersistentIdC 457 :uri "psi-1")) 458 (psi-2 (make-instance 'PersistentIdC 459 :uri "psi-2")) 460 (psi-3-1 (make-instance 'PersistentIdC 461 :uri "psi-3")) 462 (psi-3-2 (make-instance 'PersistentIdC 463 :uri "psi-3")) 464 (top-1 (make-instance 'TopicC)) 465 (top-2 (make-instance 'TopicC)) 466 (top-3 (make-instance 'TopicC)) 467 (revision 100) 468 (revision-2 200)) 469 (setf d:*TM-REVISION* revision) 470 (is-false (get-item-by-id "any-psi-id")) 471 (signals error (is-false (get-item-by-locator 472 "any-psi-id" :error-if-nil t))) 473 (signals error (is-false (get-item-by-locator 474 "any-psi-id" :error-if-nil t))) 475 (is-false (get-item-by-locator "any-psi-id")) 476 (add-psi top-1 psi-3-1 :revision revision) 477 (add-psi top-1 psi-3-2 :revision revision) 478 (signals duplicate-identifier-error 479 (get-item-by-locator "psi-3" :revision revision)) 480 (add-psi top-2 psi-1) 481 (add-psi top-2 psi-2 :revision revision-2) 482 (is (eql top-2 (get-item-by-locator "psi-1"))) 483 (is (eql top-2 (get-item-by-locator "psi-2"))) 484 (is (eql top-2 (get-item-by-locator "psi-1" :revision 500))) 485 (is-false (get-item-by-locator "psi-2" :revision revision)) 486 (delete-psi top-2 psi-1 :revision revision-2) 487 (is-false (get-item-by-locator "psi-1")) 488 (is (eql top-2 (get-item-by-locator "psi-1" :revision revision))) 489 (add-psi top-3 psi-1 :revision revision-2) 490 (is (eql top-2 (get-item-by-locator "psi-1" :revision revision))) 491 (d::add-to-version-history top-3 :start-revision revision-2) 492 (is (eql top-3 (get-item-by-locator "psi-1")))))) 493 494 366 495 (defun run-datamodel-tests() 367 496 (it.bese.fiveam:run! 'test-VersionInfoC) … … 372 501 (it.bese.fiveam:run! 'test-TopicIdentificationC) 373 502 (it.bese.fiveam:run! 'test-get-item-by-id) 503 (it.bese.fiveam:run! 'test-get-item-by-item-identifier) 504 (it.bese.fiveam:run! 'test-get-item-by-locator) 505 (it.bese.fiveam:run! 'test-get-item-by-psi) 374 506 )
Note: See TracChangeset
for help on using the changeset viewer.