]> gitweb.factorcode.org Git - factor.git/blob - extra/couchdb/couchdb-tests.factor
5b4c40e3edf5826d496bd5b03a741f8101f359a6
[factor.git] / extra / couchdb / couchdb-tests.factor
1 ! Copyright (C) 2008 Alex Chapman
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs couchdb kernel namespaces sequences strings tools.test ;
4 IN: couchdb.tests
5
6 ! You must have a CouchDB server (currently only the version from svn will
7 ! work) running on localhost and listening on the default port for these tests
8 ! to work.
9
10 <default-server> "factor-test" <db> [
11     [ ] [ couch get ensure-db ] unit-test
12     [ couch get create-db ] must-fail
13     [ ] [ couch get delete-db ] unit-test
14     [ couch get delete-db ] must-fail
15     [ ] [ couch get ensure-db ] unit-test
16     [ ] [ couch get ensure-db ] unit-test
17     [ 0 ] [ couch get db-info "doc_count" of ] unit-test
18     [ ] [ couch get compact-db ] unit-test
19     [ t ] [ couch get server>> next-uuid string? ] unit-test
20     [ ] [ H{
21             { "Subject" "I like Planktion" }
22             { "Tags" { "plankton" "baseball" "decisions" } }
23             { "Body"
24               "I decided today that I don't like baseball. I like plankton." }
25             { "Author" "Rusty" }
26             { "PostedDate" "2006-08-15T17:30:12Z-04:00" }
27            } save-doc ] unit-test
28     [ t ] [ couch get all-docs "rows" of first "id" of dup "id" set string? ] unit-test
29     [ t ] [ "id" get dup load-doc id> = ] unit-test
30     [ ] [ "id" get load-doc save-doc ] unit-test
31     [ "Rusty" ] [ "id" get load-doc "Author" of ] unit-test
32     [ ] [ "id" get load-doc "Alex" "Author" pick set-at save-doc ] unit-test
33     [ "Alex" ] [ "id" get load-doc "Author" of ] unit-test
34     [ 1 ] [ "function(doc) { emit(null, doc) }" temp-view-map "total_rows" of ] unit-test
35     [ ] [ H{
36          { "_id" "_design/posts" }
37          { "language" "javascript" }
38          { "views" H{
39              { "all" H{ { "map" "function(doc) { emit(null, doc) }" } } }
40            }
41          }
42        } save-doc ] unit-test
43     [ t ] [ "id" get load-doc delete-doc string? ] unit-test
44     [ "id" get load-doc ] must-fail
45     [ ] [ couch get delete-db ] unit-test
46 ] with-couch