97
97
assert (found == true);
101
Test.add_func ("/ShardBridge/Database/delete_then_put", () => {
102
var db = new Database (null, Database.Mode.READWRITE);
103
assert (db is Database);
105
var doc1 = new Document ("DOC-1", "rev:0", SIMPLE_DOC);
106
assert (doc1 is Document);
107
assert (db.put_doc (doc1) != null);
108
assert (db.delete_doc (doc1) != null);
109
assert (doc1.content == null);
110
assert (doc1.get_content_string () == null);
112
var nodoc = db.get_doc (doc1.id);
113
assert (nodoc.content == null);
114
assert (nodoc.get_content_string () == null);
116
doc1.set_content_string (NESTED_DOC);
119
var doc2 = db.get_doc (doc1.id);
120
assert (doc2.get_content_string () == NESTED_DOC);
102
124
void add_document_tests () {
103
125
Test.add_func ("/ShardBridge/Document/new/success", () => {
105
var expected = ("{\n" +
106
" \"foo\" : \"bar\",\n" +
108
" \"baz\" : \"beez\"\n" +
112
o = new Document ("success", "rev:0", expected);
116
assert (o is Document);
117
assert (expected == o.get_content_string ());
126
var o = new Document ("success", "rev:0", NESTED_DOC);
127
assert (o is Document);
128
assert (NESTED_DOC == o.get_content_string ());
121
131
Test.add_func ("/ShardBridge/Document/new/invalid_content", () => {
132
142
Test.add_func ("/ShardBridge/Document/new/empty", () => {
133
143
Document o = null;
135
o = new Document ("empty", "rev:0", "");
145
o = new Document ("empty", "rev:0", null);
136
146
} catch (DataError e) {
139
149
assert (o is Document);
140
assert ("{\n}" == o.get_content_string ());
150
assert (null == o.get_content_string ());