package mb import ( "testing" "github.com/stretchr/testify/assert" ) //Test band names func TestShouldBeEqualToArtist(t *testing.T) { m := NewMusicBrainz() s, _ := m.SearchForArtist("Metallica") name, _ := s.GetArtistName() assert.Equal(t, name, "Metallica") } //Test band names with spaces func TestErrShouldBeNilIfArtistIsValid(t *testing.T) { m := NewMusicBrainz() _, err := m.SearchForArtist("Iron Maiden") assert.Nil(t, err, "err should be nil for valid artist") } //Test err for existing artists func TestIfArtistIsValidThenErrIsNil(t *testing.T) { m := NewMusicBrainz() _, err := m.SearchForArtist("Metallica") assert.Nil(t, err, "err should be nil if found artist") } //Test err for invalid artists func TestErrShouldContainErrorIfArtistIsInvalid(t *testing.T) { m := NewMusicBrainz() _, err := m.SearchForArtist("difjapodsifjapdsif adspofijdas flkdsajf pakdsfad") assert.NotNil(t, err, "err should not be nil if found artist") }