Skip to content

Commit

Permalink
add a test for updated album genre tags
Browse files Browse the repository at this point in the history
related #225
  • Loading branch information
sentriz committed May 18, 2022
1 parent d6d1fe2 commit 2afc63f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions scanner/scanner_test.go
Expand Up @@ -145,6 +145,36 @@ func TestUpdatedTags(t *testing.T) {
is.Equal(updated.TagTitle, "title-upd") // updated has tags
}

// https://github.com/sentriz/gonic/issues/225
func TestUpdatedAlbumGenre(t *testing.T) {
t.Parallel()
is := is.New(t)
m := mockfs.New(t)

m.AddItems()
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.Tags) error {
tags.RawGenre = "gen-a;gen-b"
return nil
})

m.ScanAndClean()

var album db.Album
is.NoErr(m.DB().Preload("Genres").Where("left_path=? AND right_path=?", "artist-0/", "album-0").Find(&album).Error)
is.Equal(album.GenreStrings(), []string{"gen-a", "gen-b"})

m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.Tags) error {
tags.RawGenre = "gen-a-upd;gen-b-upd"
return nil
})

m.ScanAndClean()

var updated db.Album
is.NoErr(m.DB().Preload("Genres").Where("left_path=? AND right_path=?", "artist-0/", "album-0").Find(&updated).Error)
is.Equal(updated.GenreStrings(), []string{"gen-a-upd", "gen-b-upd"})
}

func TestDeleteAlbum(t *testing.T) {
t.Parallel()
is := is.NewRelaxed(t)
Expand Down

0 comments on commit 2afc63f

Please sign in to comment.