Adding GetAlbums with AlbumOptions and default values, and unit tests
Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
parent
6b742a1db4
commit
06fff46e43
8 changed files with 165 additions and 5 deletions
|
@ -2,6 +2,8 @@ package test
|
|||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/kris-nova/client-go/api/v1"
|
||||
)
|
||||
|
||||
func TestHappyGetAlbum(t *testing.T) {
|
||||
|
@ -21,3 +23,45 @@ func TestSadGetAlbum(t *testing.T) {
|
|||
t.Errorf("expected error for unknown album: %d", album.ID)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
func TestHappyGetAlbumsOptionsCount1(t *testing.T) {
|
||||
options := api.AlbumOptions{
|
||||
Count: 1,
|
||||
}
|
||||
albums, err := Client.V1().GetAlbums(&options)
|
||||
if err != nil {
|
||||
t.Errorf("expected success listing 1 album: %v", err)
|
||||
t.FailNow()
|
||||
}
|
||||
if len(albums) != 1 {
|
||||
t.Errorf("expected 1 album length, got: %d", len(albums))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
func TestHappyGetAlbumsNil(t *testing.T) {
|
||||
albums, err := Client.V1().GetAlbums(nil)
|
||||
if err != nil {
|
||||
t.Errorf("expected success listing albums: %v", err)
|
||||
t.FailNow()
|
||||
}
|
||||
t.Logf("Listed %d albums", len(albums))
|
||||
}
|
||||
|
||||
func TestSadGetAlbums(t *testing.T) {
|
||||
options := api.AlbumOptions{
|
||||
Category: UnknownCategory,
|
||||
}
|
||||
albums, err := Client.V1().GetAlbums(&options)
|
||||
if err != nil {
|
||||
t.Errorf("error listing albums: %v", err)
|
||||
t.FailNow()
|
||||
return
|
||||
}
|
||||
|
||||
// Note: by defualt we return "{}" which counts as 1 album
|
||||
if len(albums) != 1 {
|
||||
t.Errorf("Non zero length of albums")
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue