pub async fn init_test_database_with_state<SCF>(
song_count: NonZero<usize>,
song_case_func: SCF,
dynamic: Option<DynamicPlaylist>,
tempdir: &TempDir,
) -> Arc<Surreal<Db>>Expand description
Initialize a test database with some basic state
§What will be created:
- a playlist named “Playlist 0”
- a collection named “Collection 0”
- optionally, a passed
DynamicPlaylist song_countarbitrary songs whose values are determined by the givensong_case_func- a file in the given
TempDirfor each song
Can optionally also create a dynamic playlist with given information
You can pass functions to be used to create the songs and playlists
song_case_func signature
FnMut(usize) -> (SongCase, bool, bool)
i: which song this is, 0..song_count- returns:
(the song_case to use when generating the song, whether the song should be added to the playlist, whether it should be added to the collection
Note: will actually create files for the songs in the passed TempDir
§Panics
Panics if an error occurs during the above process, this is intended to only be used for testing so panicking when something goes wrong ensures that tests will fail and the backtrace will point to whatever line caused the panic in here.