mb_test.go 960 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package mb
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. //Test band names
  7. func TestShouldBeEqualToArtist(t *testing.T) {
  8. m := NewMusicBrainz()
  9. s, _ := m.SearchForArtist("Metallica")
  10. name, _ := s.GetArtistName()
  11. assert.Equal(t, name, "Metallica")
  12. }
  13. //Test band names with spaces
  14. func TestErrShouldBeNilIfArtistIsValid(t *testing.T) {
  15. m := NewMusicBrainz()
  16. _, err := m.SearchForArtist("Iron Maiden")
  17. assert.Nil(t, err, "err should be nil for valid artist")
  18. }
  19. //Test err for existing artists
  20. func TestIfArtistIsValidThenErrIsNil(t *testing.T) {
  21. m := NewMusicBrainz()
  22. _, err := m.SearchForArtist("Metallica")
  23. assert.Nil(t, err, "err should be nil if found artist")
  24. }
  25. //Test err for invalid artists
  26. func TestErrShouldContainErrorIfArtistIsInvalid(t *testing.T) {
  27. m := NewMusicBrainz()
  28. _, err := m.SearchForArtist("difjapodsifjapdsif adspofijdas flkdsajf pakdsfad")
  29. assert.NotNil(t, err, "err should not be nil if found artist")
  30. }