More getMusicDirectory

This commit is contained in:
Deluan
2016-03-02 20:50:16 -05:00
parent 9577d9ae87
commit 4f5af423a8
4 changed files with 63 additions and 16 deletions
+21 -5
View File
@@ -14,13 +14,13 @@ import (
func TestGetMusicDirectory(t *testing.T) {
Init(t, false)
mockRepo := mocks.CreateMockArtistRepo()
mockArtistRepo := mocks.CreateMockArtistRepo()
utils.DefineSingleton(new(domain.ArtistRepository), func() domain.ArtistRepository {
return mockRepo
return mockArtistRepo
})
mockRepo.SetData("[]")
mockRepo.SetError(false)
mockArtistRepo.SetData("[]", 0)
mockArtistRepo.SetError(false)
Convey("Subject: GetMusicDirectory Endpoint", t, func() {
Convey("Should fail if missing Id parameter", func() {
@@ -30,11 +30,27 @@ func TestGetMusicDirectory(t *testing.T) {
})
Convey("Id is for an artist", func() {
Convey("Return fail on Artist Table error", func() {
mockRepo.SetError(true)
mockArtistRepo.SetError(true)
_, w := Get(AddParams("/rest/getMusicDirectory.view", "id=1"), "TestGetMusicDirectory")
So(w.Body, ShouldReceiveError, responses.ERROR_GENERIC)
})
})
Convey("When id is not found", func() {
mockArtistRepo.SetData(`[{"Id":"1","Name":"The Charlatans"}]`, 1)
_, w := Get(AddParams("/rest/getMusicDirectory.view", "id=NOT_FOUND"), "TestGetMusicDirectory")
So(w.Body, ShouldReceiveError, responses.ERROR_DATA_NOT_FOUND)
})
Convey("When id matches an artist without albums", func() {
mockArtistRepo.SetData(`[{"Id":"1","Name":"The KLF"}]`, 1)
_, w := Get(AddParams("/rest/getMusicDirectory.view", "id=1"), "TestGetMusicDirectory")
So(w.Body, ShouldContainJSON, `"id":"1","name":"The KLF"`)
})
Reset(func() {
mockArtistRepo.SetData("[]", 0)
mockArtistRepo.SetError(false)
})
})
}