Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
test_removed_image_repository.c File Reference
+ Include dependency graph for test_removed_image_repository.c:

Go to the source code of this file.

Macros

#define SEEDED_FLAGS   0x51
 
#define SEEDED_VERSION   7
 

Functions

static void _seed_every_table (const int32_t imgid, const char *tag_name, const char *meta_value)
 
static void _remove (const int32_t imgid)
 
static gboolean _in_group (const int32_t group_id, const int32_t imgid)
 
static gboolean _has_flags (const int32_t imgid, const int flags)
 
static void test_round_trip_restores_every_table (void **state)
 
static void test_group_leader_restores_membership (void **state)
 
static void test_film_roll_comes_back_with_its_last_image (void **state)
 
static void test_partial_undo_repoints_a_departed_leader (void **state)
 
static void test_whole_group_removed_and_fully_undone_keeps_one_group (void **state)
 
static void test_clear_drops_the_snapshot (void **state)
 
static void test_successive_snapshots_do_not_collide (void **state)
 
int main (void)
 

Macro Definition Documentation

◆ SEEDED_FLAGS

#define SEEDED_FLAGS   0x51

The contract behind "undo remove from library" (doc/removal-undo.md).

Removing an image deletes its main.images row and the foreign keys take its history, masks, tags, colour labels, metadata, module order and history end with it. The undo can only be as good as what was staged first, so what these tests pin is that a snapshot is COMPLETE – every table comes back, not merely the image row, which is the failure this design is exposed to: a restore that looks right because the image is listed again while its edit is gone.

Two properties beyond the round trip get their own tests, because both are invisible in the common case and wrong only at the edges: the group membership of images NOBODY asked to remove (rewritten on the way out, staged separately), and the film roll (swept when its last image goes, and referenced by a foreign key on the way back).

The removal itself is spelled out here rather than called: dt_image_remove_undoable() lives in common/image.c and drags the image cache, the mipmap cache and the undo stack in with it. What is under test is the repository, so _remove() below reproduces the only two database effects the job has – the grouping hand-over and the row delete – through the repository API, the same way testdb.h requires of every test here.

Note what is NOT used: dt_image_repository_load(). It maps the row through dt_image_film_roll_name(), which reads a conf key, and this fixture initialises no conf system. Every assertion below therefore reads its column through a narrower query.

Definition at line 49 of file test_removed_image_repository.c.

◆ SEEDED_VERSION

#define SEEDED_VERSION   7

Definition at line 51 of file test_removed_image_repository.c.

Function Documentation

◆ _has_flags()

static gboolean _has_flags ( const int32_t  imgid,
const int  flags 
)
static

◆ _in_group()

◆ _remove()

◆ _seed_every_table()

◆ main()

◆ test_clear_drops_the_snapshot()

◆ test_film_roll_comes_back_with_its_last_image()

◆ test_group_leader_restores_membership()

static void test_group_leader_restores_membership ( void **  state)
static

◆ test_partial_undo_repoints_a_departed_leader()

◆ test_round_trip_restores_every_table()

◆ test_successive_snapshots_do_not_collide()

◆ test_whole_group_removed_and_fully_undone_keeps_one_group()