Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
testdb.h
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18
34#ifndef DT_TESTS_UNITTESTS_TESTDB_H
35#define DT_TESTS_UNITTESTS_TESTDB_H
36
37#include <stdarg.h>
38#include <stddef.h>
39#include <setjmp.h>
40#include <stdint.h>
41#include <cmocka.h>
42
45#include "database/database.h"
54
55static inline int testdb_setup(void **state)
56{
57 (void)state;
58 const dt_database_params_t params = { .alternative = NULL,
59 .library = ":memory:",
60 .load_data = FALSE,
61 .has_gui = FALSE,
62 .verbose = FALSE };
63 return dt_database_open(&params) == DT_DATABASE_OPEN_OK ? 0 : -1;
64}
65
66static inline int testdb_teardown(void **state)
67{
68 (void)state;
69 /* Every cleanup is idempotent and safe for repositories the test never touched. The
70 * connection cannot close over a live statement, so this order is load-bearing. */
81 return 0;
82}
83
85static inline int32_t testdb_make_film(const char *folder)
86{
87 if(!dt_film_repository_insert(folder)) return -1;
89}
90
92static inline int32_t testdb_make_image(const int32_t film_id, const char *filename)
93{
94 if(!dt_image_repository_insert_import(film_id, filename, 0, 1000)) return -1;
95 return dt_image_repository_find_by_film_and_filename(film_id, filename);
96}
97
98#endif // DT_TESTS_UNITTESTS_TESTDB_H
#define FALSE
Definition ashift_lsd.c:158
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
void dt_collection_query_cleanup(void)
void dt_colorlabel_repository_cleanup(void)
Finalise whatever this repository still caches – today, nothing.
main.color_labels: which of the five colour labels are set on an image.
void dt_database_close(void)
Definition database.c:3720
dt_database_open_result_t dt_database_open(const dt_database_params_t *params)
Definition database.c:3603
@ DT_DATABASE_OPEN_OK
Definition database.h:78
gboolean dt_film_repository_insert(const char *folder)
int32_t dt_film_repository_find_by_folder(const char *folder)
void dt_history_repository_cleanup(void)
void dt_image_repository_cleanup(void)
Finalise the prepared statements. Called at shutdown, after the last cache release and before the dat...
int32_t dt_image_repository_find_by_film_and_filename(const int32_t film_id, const char *filename)
The image id for filename inside film roll film_id, or -1.
gboolean dt_image_repository_insert_import(const int32_t film_id, const char *filename, const int flags, const int64_t import_timestamp)
Insert a bare row for a file being imported, returning TRUE on success.
Reading and writing one dt_image_t to and from the library database. The SQL half of what used to be ...
void dt_metadata_repository_cleanup(void)
Finalise the prepared statements. See dt_colorlabel_repository_cleanup().
main.meta_data: the free-text image metadata (title, description, creator, publisher,...
void dt_preset_repository_cleanup(void)
Finalise the cached statements. See dt_colorlabel_repository_cleanup().
data.presets: a module's saved parameters, with the conditions under which it auto-applies.
void dt_selection_repository_cleanup(void)
Finalise whatever this repository still caches – today, nothing. See dt_colorlabel_repository_cleanup...
main.selected_images, and the memory.selected_backup it is pushed onto.
const float uint32_t state[4]
void dt_style_repository_cleanup(void)
void dt_tag_repository_cleanup(void)
Finalise whatever this repository still caches – today, nothing. See dt_colorlabel_repository_cleanup...
data.tags and main.tagged_images.
static int testdb_setup(void **state)
Definition testdb.h:55
static int32_t testdb_make_film(const char *folder)
Definition testdb.h:85
static int testdb_teardown(void **state)
Definition testdb.h:66
static int32_t testdb_make_image(const int32_t film_id, const char *filename)
Definition testdb.h:92