mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-02 11:21:35 +03:00
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package api_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/deluan/gosonic/domain"
|
|
"github.com/deluan/gosonic/tests/mocks"
|
|
"github.com/deluan/gosonic/utils"
|
|
. "github.com/deluan/gosonic/tests"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
"github.com/deluan/gosonic/api/responses"
|
|
)
|
|
|
|
func TestGetMusicDirectory(t *testing.T) {
|
|
Init(t, false)
|
|
|
|
mockRepo := mocks.CreateMockArtistRepo()
|
|
utils.DefineSingleton(new(domain.ArtistRepository), func() domain.ArtistRepository {
|
|
return mockRepo
|
|
})
|
|
|
|
mockRepo.SetData("[]")
|
|
mockRepo.SetError(false)
|
|
|
|
Convey("Subject: GetMusicDirectory Endpoint", t, func() {
|
|
Convey("Should fail if missing Id parameter", func() {
|
|
_, w := Get(AddParams("/rest/getMusicDirectory.view"), "TestGetMusicDirectory")
|
|
|
|
So(w.Body, ShouldReceiveError, responses.ERROR_MISSING_PARAMETER)
|
|
})
|
|
Convey("Id is for an artist", func() {
|
|
Convey("Return fail on Artist Table error", func() {
|
|
mockRepo.SetError(true)
|
|
_, w := Get(AddParams("/rest/getMusicDirectory.view", "id=1"), "TestGetMusicDirectory")
|
|
|
|
So(w.Body, ShouldReceiveError, responses.ERROR_GENERIC)
|
|
})
|
|
})
|
|
})
|
|
} |