tests: file lists [not finished]
This commit is contained in:
+32
-6
@@ -11,18 +11,44 @@
|
||||
#include <file_p.h>
|
||||
#include <main.h>
|
||||
#include <string.h>
|
||||
/* TODO: complete */
|
||||
#include <sys/cdefs.h>
|
||||
#include <unistd.h>
|
||||
|
||||
dbuf_t *dbuf;
|
||||
|
||||
fl_t fl_sample = {
|
||||
.name = "test_file", .description = "Hello test file", .owner = "user1234"};
|
||||
.name = "test_file", .description = "Hello test file", .owner = "user1234", .next = NULL};
|
||||
|
||||
ssize_t __wrap_write(int __fd, const void *__buf, size_t __n) __wur {
|
||||
dbuf_write(__buf, __n, &dbuf);
|
||||
return __n;
|
||||
}
|
||||
|
||||
int32_t __wrap_db_get_files_data(i_get_files_db *arg, fl_t **fl_start,
|
||||
int32_t *full_count) {
|
||||
fill_list_with_samples(&fl_sample, fl_start, NULL, 123);
|
||||
*full_count = 123;
|
||||
return 123;
|
||||
fill_list_with_samples(&fl_sample, fl_start, NULL, arg->limit);
|
||||
*full_count = arg->limit;
|
||||
return arg->limit;
|
||||
}
|
||||
|
||||
void test__file_list(void **state) {}
|
||||
#define COUNT 20
|
||||
|
||||
void test__file_list(void **state) {
|
||||
session sess = {
|
||||
.fl_start = NULL,
|
||||
.fl_current = NULL,
|
||||
.uname = "user1234",
|
||||
};
|
||||
i_file_list_t fl_args = {.page = 1, .limit = COUNT, .name = NULL};
|
||||
dbuf = dbuf_init(INBUFSIZE);
|
||||
file_list(&sess, &fl_args);
|
||||
assert_int_not_equal(dbuf->len, 0);
|
||||
char *end_str = strstr(dbuf->ptr, ":END: PAGE");
|
||||
char strcmp[128];
|
||||
sprintf(strcmp, ":END: PAGE 1/1 COUNT: %d/%d\n", COUNT, COUNT);
|
||||
assert_string_equal(strcmp, end_str);
|
||||
dbuf_destroy(&dbuf);
|
||||
}
|
||||
|
||||
int setup(void **state) { return 0; }
|
||||
int tear_down(void **state) { return 0; }
|
||||
|
||||
Reference in New Issue
Block a user