Skip to content

Commit

Permalink
test: add test cases for fetching and parsing album data
Browse files Browse the repository at this point in the history
  • Loading branch information
ghoshRitesh12 committed Jul 21, 2024
1 parent 5ad6a65 commit 2fdeef6
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions parsers/album_test.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
package parsers_test

import (
"fmt"
"testing"

"github.com/davecgh/go-spew/spew"
"github.com/ghoshRitesh12/brooktube"
"github.com/stretchr/testify/assert"
)

// go test -run TestGetAlbum ./parsers -v -count=1
func TestGetAlbum(t *testing.T) {
const KAMIMAZE_ALBUM_ID = "OLAK5uy_kRVaDLvDemKrwYjkdUTryKHIyQa_RiiPo"
// const THE_EMINEM_SHOW_ALBUM_ID = "OLAK5uy_lqWe7SUa0zi9eDcuCSCi1eeiakfPi2skg"
brooktube := brooktube.New()

album, err := brooktube.GetAlbum(KAMIMAZE_ALBUM_ID)
if err != nil {
t.Error(err)
testsTable := []struct {
albumName string
albumId string
}{
{"kamikaze", "OLAK5uy_kRVaDLvDemKrwYjkdUTryKHIyQa_RiiPo"},
{"the eminem show", "OLAK5uy_kkypLq7TlpT3uYdH3MbuHDiF2J3u-BRjc"},
{"the eminem show expanded version", "OLAK5uy_lqWe7SUa0zi9eDcuCSCi1eeiakfPi2skg"},
}

spew.Dump(album, len(album.Songs))
btube := brooktube.New()

for _, test := range testsTable {
t.Run(test.albumName, func(t *testing.T) {
album, err := btube.GetAlbum(test.albumId)

assert.NoError(t, err)
assert.NotNil(t, album)

spew.Dump(album, len(album.Tracks))
fmt.Println()
})
}
}

0 comments on commit 2fdeef6

Please sign in to comment.