summaryrefslogtreecommitdiff
path: root/tests/storage_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/storage_test.c')
-rw-r--r--tests/storage_test.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/storage_test.c b/tests/storage_test.c
index 0343f46..5c343d0 100644
--- a/tests/storage_test.c
+++ b/tests/storage_test.c
@@ -193,6 +193,40 @@ main(void)
tiny_sys_file_close(&log);
CHECK(tiny_store_open(&store, directory) == TINY_STORE_CORRUPT);
+ {
+ char *tail_directory = tiny_sys_path_join(temporary_root, "snapshot-tail");
+ tiny_store_t *tail_store = NULL;
+ tiny_message_t tail_input, tail_put;
+ tiny_store_health_t tail_health;
+ CHECK(tail_directory != NULL);
+ CHECK(tiny_sys_directory_create(tail_directory) == TINY_SYS_OK);
+ CHECK(tiny_store_open(&tail_store, tail_directory) == TINY_STORE_OK);
+ tiny_message_init(&tail_input);
+ tiny_message_init(&tail_put);
+ tail_input.session_id = duplicate_string("tail");
+ tail_input.content = duplicate_string("snapshot base");
+ tail_input.role = TINY_ROLE_USER;
+ CHECK(tiny_store_write(tail_store, &tail_input, &tail_put) == TINY_STORE_OK);
+ CHECK(tiny_store_rebuild(tail_store, &report) == TINY_STORE_OK);
+ tiny_store_health(tail_store, &tail_health);
+ CHECK(tail_health.snapshot_valid);
+ free(tail_input.content);
+ tail_input.content = duplicate_string("tail put then delete");
+ tiny_message_free(&tail_put);
+ CHECK(tiny_store_write(tail_store, &tail_input, &tail_put) == TINY_STORE_OK);
+ CHECK(tiny_store_delete(tail_store, tail_put.message_id, "tail") == TINY_STORE_OK);
+ tiny_message_free(&tail_input);
+ tiny_message_free(&tail_put);
+ tiny_store_close(tail_store);
+ tail_store = NULL;
+ CHECK(tiny_store_open(&tail_store, tail_directory) == TINY_STORE_OK);
+ CHECK(tiny_store_entry_count(tail_store) == 2);
+ CHECK(!tiny_store_entry(tail_store, 0)->deleted);
+ CHECK(tiny_store_entry(tail_store, 1)->deleted);
+ tiny_store_close(tail_store);
+ free(tail_directory);
+ }
+
(void)tiny_sys_file_remove(log_path);
(void)tiny_sys_file_remove(temporary_path);
(void)tiny_sys_file_remove(lock_path);