Files
dusk/test/save/savetestfixture.h
T
YourWishesandClaude Sonnet 5 7a9a2b9832 Add order-based party roster, back-navigation in battle selection, fix win-state cutscene leak
- Battle selection menu can now go back a fighter to re-decide their move,
  and battle win/loss no longer leaks the round's remaining queued move
  cutscenes into the ending state (cutsceneSystemDiscardQueued).
- Party roster is now driven by party.jsonc: every defined member always
  exists (partyInit), while party->order alone determines who's currently
  active - partyAddMember/partyRemoveMember (and their cutscene items) now
  activate/deactivate an existing roster member by index instead of
  creating/destroying one, with removal compacting order to stay packed.
- New PARTY_ADD_MEMBER/PARTY_REMOVE_MEMBER/PARTY_HEAL_MEMBER/PARTY_HEAL_ALL
  cutscene items.
- saveSlotInit/partyInit now return errorret_t and take their target
  struct directly (saveslot_t*/party_t*) instead of implicitly operating
  on SAVE.slot; saveSlotReadJSON resets through saveSlotInit rather than
  duplicating the reset logic.
- Test coverage: stub the JSON asset loader in save test fixtures so
  partyInit's real party.jsonc load runs against an in-memory doc instead
  of hanging with no asset system initialized.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-09-21 22:27:46 -05:00

56 lines
2.2 KiB
C

/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "save/save.h"
/**
* Points $HOME at a fresh, empty temporary directory and resets the global
* SAVE state via the real saveInit(). Save tests run against the real Linux
* filesystem backend (there is no fake/mockable platform layer to swap in -
* the platform hooks are compile-time macros, not function pointers), so
* this sandboxing is what keeps tests from touching the real user's
* $HOME/.dusk/saves. Matches cmocka's CMUnitTestSetup signature - pass
* directly to cmocka_unit_test_setup_teardown.
*/
int saveTestFixtureSetup(void **state);
/**
* Recursively removes the temporary $HOME directory tree created by
* saveTestFixtureSetup and restores the real $HOME. Matches cmocka's
* CMUnitTestTeardown signature - pass directly to
* cmocka_unit_test_setup_teardown.
*/
int saveTestFixtureTeardown(void **state);
/**
* Places a regular file where the ".dusk" directory needs to go, so a
* subsequent availability check's mkdirp() call fails with ENOTDIR instead
* of succeeding. Used to deterministically exercise the "device unavailable
* because its directory couldn't be created" path without relying on real
* filesystem permission tricks. Must be called after saveTestFixtureSetup.
*/
void saveTestFixtureBlockSaveDirectory(void);
/**
* Stubs the JSON asset loader's sync callback to hand back a small
* in-memory party.jsonc-shaped doc instead of doing a real file/zip read -
* saveInit()/saveSlotInit() seed the party roster via partyInit(), which
* loads party.jsonc through the real asset system, and there's no real
* asset bundle available under the test harness. No thread, no real I/O.
* Resets ASSET to a fresh, otherwise-empty state each call, so it's safe
* to call once per test. Called automatically by saveTestFixtureSetup.
*/
void saveTestFixtureStubPartyAsset(void);
/**
* Frees the in-memory doc created by saveTestFixtureStubPartyAsset. Safe
* to call even if that function was never called. Called automatically
* by saveTestFixtureTeardown.
*/
void saveTestFixtureUnstubPartyAsset(void);