@@ -53,7 +53,7 @@ FOSSIL_TEARDOWN(c_noshell_fixture) {
5353
5454FOSSIL_TEST (c_test_noshell_create_open_delete ) {
5555 fossil_bluecrab_noshell_error_t err ;
56- const char * file_name = "test_noshell.crabdb " ;
56+ const char * file_name = "test_noshell.noshell " ;
5757
5858 err = fossil_bluecrab_noshell_create_database (file_name );
5959 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
@@ -67,9 +67,9 @@ FOSSIL_TEST(c_test_noshell_create_open_delete) {
6767
6868FOSSIL_TEST (c_test_noshell_insert_find_remove ) {
6969 fossil_bluecrab_noshell_error_t err ;
70- const char * file_name = "test_noshell_insert.crabdb " ;
71- const char * doc = "{\"user\": \"alice\",\"pass\": \"secret\"}" ;
72- const char * type = "user " ;
70+ const char * file_name = "test_noshell_insert.noshell " ;
71+ const char * doc = "{ username: cstr: \"alice\", password: cstr: \"secret\" }" ;
72+ const char * type = "object " ;
7373
7474 err = fossil_bluecrab_noshell_create_database (file_name );
7575 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
@@ -78,24 +78,24 @@ FOSSIL_TEST(c_test_noshell_insert_find_remove) {
7878 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
7979
8080 char result [128 ];
81- err = fossil_bluecrab_noshell_find (file_name , "user=alice " , result , sizeof (result ), type );
81+ err = fossil_bluecrab_noshell_find (file_name , "username " , result , sizeof (result ), type );
8282 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
83- ASSUME_ITS_TRUE (strstr (result , doc ) != NULL );
83+ ASSUME_ITS_TRUE (strstr (result , "alice" ) != NULL );
8484
85- err = fossil_bluecrab_noshell_remove (file_name , "user=alice " );
85+ err = fossil_bluecrab_noshell_remove (file_name , "username " );
8686 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
8787
88- err = fossil_bluecrab_noshell_find (file_name , "user=alice " , result , sizeof (result ), type );
88+ err = fossil_bluecrab_noshell_find (file_name , "username " , result , sizeof (result ), type );
8989 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_NOT_FOUND );
9090
9191 fossil_bluecrab_noshell_delete_database (file_name );
9292}
9393
9494FOSSIL_TEST (c_test_noshell_insert_with_id ) {
9595 fossil_bluecrab_noshell_error_t err ;
96- const char * file_name = "test_noshell_with_id.crabdb " ;
97- const char * doc = "{\" item\": \"book\"}" ;
98- const char * type = "item " ;
96+ const char * file_name = "test_noshell_with_id.noshell " ;
97+ const char * doc = "{ item: cstr: \"book\" }" ;
98+ const char * type = "object " ;
9999 char doc_id [64 ];
100100
101101 err = fossil_bluecrab_noshell_create_database (file_name );
@@ -107,42 +107,42 @@ FOSSIL_TEST(c_test_noshell_insert_with_id) {
107107 char result [128 ];
108108 err = fossil_bluecrab_noshell_find (file_name , doc_id , result , sizeof (result ), type );
109109 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
110- ASSUME_ITS_TRUE (strstr (result , doc ) != NULL );
110+ ASSUME_ITS_TRUE (strstr (result , "book" ) != NULL );
111111
112112 fossil_bluecrab_noshell_delete_database (file_name );
113113}
114114
115115FOSSIL_TEST (c_test_noshell_update ) {
116116 fossil_bluecrab_noshell_error_t err ;
117- const char * file_name = "test_noshell_update.crabdb " ;
118- const char * doc = "{\" name\": \"bob\"}" ;
119- const char * new_doc = "{\" name\": \"bob\",\" age\":30 }" ;
120- const char * type = "person " ;
117+ const char * file_name = "test_noshell_update.noshell " ;
118+ const char * doc = "{ name: cstr: \"bob\" }" ;
119+ const char * new_doc = "{ name: cstr: \"bob\", age: i32: 30 }" ;
120+ const char * type = "object " ;
121121
122122 err = fossil_bluecrab_noshell_create_database (file_name );
123123 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
124124
125125 err = fossil_bluecrab_noshell_insert (file_name , doc , NULL , type );
126126 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
127127
128- err = fossil_bluecrab_noshell_update (file_name , "name=bob " , new_doc , NULL , type );
128+ err = fossil_bluecrab_noshell_update (file_name , "name" , new_doc , NULL , type );
129129 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
130130
131131 char result [128 ];
132- err = fossil_bluecrab_noshell_find (file_name , "name=bob " , result , sizeof (result ), type );
132+ err = fossil_bluecrab_noshell_find (file_name , "name" , result , sizeof (result ), type );
133133 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
134- ASSUME_ITS_TRUE (strstr (result , new_doc ) != NULL );
134+ ASSUME_ITS_TRUE (strstr (result , "age: i32: 30" ) != NULL );
135135
136136 fossil_bluecrab_noshell_delete_database (file_name );
137137}
138138
139139FOSSIL_TEST (c_test_noshell_backup_restore ) {
140140 fossil_bluecrab_noshell_error_t err ;
141- const char * file_name = "test_noshell_backup.crabdb " ;
142- const char * backup_file = "test_noshell_backup.bak " ;
143- const char * restore_file = "test_noshell_restored.crabdb " ;
144- const char * doc = "{\"x\":1 }" ;
145- const char * type = "data " ;
141+ const char * file_name = "test_noshell_backup.noshell " ;
142+ const char * backup_file = "test_noshell_backup_file.noshell " ;
143+ const char * restore_file = "test_noshell_restored.noshell " ;
144+ const char * doc = "{ x: i32: 1 }" ;
145+ const char * type = "object " ;
146146
147147 err = fossil_bluecrab_noshell_create_database (file_name );
148148 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
@@ -156,10 +156,14 @@ FOSSIL_TEST(c_test_noshell_backup_restore) {
156156 err = fossil_bluecrab_noshell_restore_database (backup_file , restore_file );
157157 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
158158
159+ // Ensure the restored database is opened before querying
160+ err = fossil_bluecrab_noshell_open_database (restore_file );
161+ ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
162+
159163 char result [128 ];
160- err = fossil_bluecrab_noshell_find (restore_file , "x=1 " , result , sizeof (result ), type );
164+ err = fossil_bluecrab_noshell_find (restore_file , "x" , result , sizeof (result ), type );
161165 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
162- ASSUME_ITS_TRUE (strstr (result , doc ) != NULL );
166+ ASSUME_ITS_TRUE (strstr (result , "x: i32: 1" ) != NULL );
163167
164168 fossil_bluecrab_noshell_delete_database (file_name );
165169 fossil_bluecrab_noshell_delete_database (restore_file );
@@ -168,14 +172,14 @@ FOSSIL_TEST(c_test_noshell_backup_restore) {
168172
169173FOSSIL_TEST (c_test_noshell_count_and_size ) {
170174 fossil_bluecrab_noshell_error_t err ;
171- const char * file_name = "test_noshell_count.crabdb " ;
172- const char * type = "count " ;
175+ const char * file_name = "test_noshell_count.noshell " ;
176+ const char * type = "object " ;
173177 err = fossil_bluecrab_noshell_create_database (file_name );
174178 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
175179
176- err = fossil_bluecrab_noshell_insert (file_name , "{\"a\":1 }" , NULL , type );
180+ err = fossil_bluecrab_noshell_insert (file_name , "{ a: i32: 1 }" , NULL , type );
177181 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
178- err = fossil_bluecrab_noshell_insert (file_name , "{\"b\":2 }" , NULL , type );
182+ err = fossil_bluecrab_noshell_insert (file_name , "{ b: i32: 2 }" , NULL , type );
179183 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
180184
181185 size_t count = 0 ;
@@ -193,14 +197,14 @@ FOSSIL_TEST(c_test_noshell_count_and_size) {
193197
194198FOSSIL_TEST (c_test_noshell_first_next_document ) {
195199 fossil_bluecrab_noshell_error_t err ;
196- const char * file_name = "test_noshell_iter.crabdb " ;
197- const char * type = "iter " ;
200+ const char * file_name = "test_noshell_iter.noshell " ;
201+ const char * type = "object " ;
198202 err = fossil_bluecrab_noshell_create_database (file_name );
199203 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
200204
201- err = fossil_bluecrab_noshell_insert (file_name , "{\"id\":1 }" , NULL , type );
205+ err = fossil_bluecrab_noshell_insert (file_name , "{ id: i32: 1 }" , NULL , type );
202206 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
203- err = fossil_bluecrab_noshell_insert (file_name , "{\"id\":2 }" , NULL , type );
207+ err = fossil_bluecrab_noshell_insert (file_name , "{ id: i32: 2 }" , NULL , type );
204208 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
205209
206210 char id1 [64 ], id2 [64 ];
@@ -219,12 +223,12 @@ FOSSIL_TEST(c_test_noshell_first_next_document) {
219223
220224FOSSIL_TEST (c_test_noshell_verify_database ) {
221225 fossil_bluecrab_noshell_error_t err ;
222- const char * file_name = "test_noshell_verify.crabdb " ;
223- const char * type = "verify " ;
226+ const char * file_name = "test_noshell_verify.noshell " ;
227+ const char * type = "object " ;
224228 err = fossil_bluecrab_noshell_create_database (file_name );
225229 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
226230
227- err = fossil_bluecrab_noshell_insert (file_name , "{\"v\":42 }" , NULL , type );
231+ err = fossil_bluecrab_noshell_insert (file_name , "{ v: i32: 42 }" , NULL , type );
228232 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
229233
230234 err = fossil_bluecrab_noshell_verify_database (file_name );
@@ -234,15 +238,15 @@ FOSSIL_TEST(c_test_noshell_verify_database) {
234238}
235239
236240FOSSIL_TEST (c_test_noshell_validate_helpers ) {
237- ASSUME_ITS_TRUE (fossil_bluecrab_noshell_validate_extension ("foo.crabdb " ));
241+ ASSUME_ITS_TRUE (fossil_bluecrab_noshell_validate_extension ("foo.noshell " ));
238242 ASSUME_ITS_TRUE (!fossil_bluecrab_noshell_validate_extension ("foo.txt" ));
239- ASSUME_ITS_TRUE (fossil_bluecrab_noshell_validate_document ("{\"ok\": true}" ));
243+ ASSUME_ITS_TRUE (fossil_bluecrab_noshell_validate_document ("{ ok: bool: true }" ));
240244 ASSUME_ITS_TRUE (!fossil_bluecrab_noshell_validate_document ("not_a_json" ));
241245}
242246
243247FOSSIL_TEST (c_test_noshell_lock_unlock_is_locked ) {
244248 fossil_bluecrab_noshell_error_t err ;
245- const char * file_name = "test_noshell_lock.crabdb " ;
249+ const char * file_name = "test_noshell_lock.noshell " ;
246250 err = fossil_bluecrab_noshell_create_database (file_name );
247251 ASSUME_ITS_TRUE (err == FOSSIL_NOSHELL_ERROR_SUCCESS );
248252
0 commit comments