core/tags/artist: Add an artist_db_get() function

This will be called to scan the artist database when setting up
playlists.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-05-15 10:17:30 -04:00 committed by Anna Schumaker
parent b3922cc731
commit 20e0a85a5d
3 changed files with 12 additions and 0 deletions

View File

@ -68,6 +68,11 @@ void artist_db_deinit()
db_deinit(&artist_db);
}
const struct database *artist_db_get()
{
return &artist_db;
}
struct artist *artist_find(const gchar *name)
{
return ARTIST(db_find(&artist_db, name));

View File

@ -31,6 +31,9 @@ void artist_db_init();
/* Called to clean up the artist database. */
void artist_db_deinit();
/* Called to access the artist database. */
const struct database *artist_db_get();
/*
* Called to find an artist tag by name. The difference is that artist_find()
* will allocate a new artiststruct if the requested one doesn't exist yet,

View File

@ -79,12 +79,16 @@ static void test_artist_db()
struct database artist_db;
struct artist *artist;
test_not_equal((void *)artist_db_get(), NULL);
test_equal(artist_db_get()->db_size, 0);
artist_db_init();
artist = artist_lookup("Koji Kondo");
test_equal((void *)artist, NULL);
artist = artist_find("Koji Kondo");
test_verify_koji(artist);
test_equal(artist_db_get()->db_size, 1);
test_equal((void *)artist_lookup("Koji Kondo"), (void *)artist);
test_equal((void *)artist_find("Koji Kondo"), (void *)artist);
test_equal((void *)artist_get(0), (void *)artist);