diff --git a/controllers/get_license.go b/controllers/get_license.go index cce7d8be9..142212f7f 100644 --- a/controllers/get_license.go +++ b/controllers/get_license.go @@ -2,7 +2,7 @@ package controllers import ( "github.com/astaxie/beego" - "github.com/deluan/gosonic/responses" + "github.com/deluan/gosonic/controllers/responses" ) type GetLicenseController struct{ beego.Controller } diff --git a/controllers/get_music_folders.go b/controllers/get_music_folders.go new file mode 100644 index 000000000..2d3293679 --- /dev/null +++ b/controllers/get_music_folders.go @@ -0,0 +1 @@ +package controllers diff --git a/controllers/ping.go b/controllers/ping.go index 4af00246b..df2098ce4 100644 --- a/controllers/ping.go +++ b/controllers/ping.go @@ -3,7 +3,7 @@ package controllers import ( "github.com/astaxie/beego" "encoding/xml" - "github.com/deluan/gosonic/responses" + "github.com/deluan/gosonic/controllers/responses" ) type PingController struct{ beego.Controller } diff --git a/responses/license.go b/controllers/responses/license.go similarity index 100% rename from responses/license.go rename to controllers/responses/license.go diff --git a/responses/subsonic.go b/controllers/responses/subsonic.go similarity index 100% rename from responses/subsonic.go rename to controllers/responses/subsonic.go diff --git a/tests/controllers/get_music_folders_test.go b/tests/controllers/get_music_folders_test.go new file mode 100644 index 000000000..89d706245 --- /dev/null +++ b/tests/controllers/get_music_folders_test.go @@ -0,0 +1,36 @@ +package test + +import ( + "net/http" + "net/http/httptest" + "testing" + "runtime" + "path/filepath" + _ "github.com/deluan/gosonic/routers" + + "github.com/astaxie/beego" + . "github.com/smartystreets/goconvey/convey" + "fmt" +) + +func init() { + _, file, _, _ := runtime.Caller(1) + appPath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, "../.." + string(filepath.Separator)))) + beego.TestBeegoInit(appPath) +} + +// TestGet is a sample to run an endpoint test +func TestGetMusicFolders(t *testing.T) { + r, _ := http.NewRequest("GET", "/rest/getMusicFolders.view", nil) + w := httptest.NewRecorder() + beego.BeeApp.Handlers.ServeHTTP(w, r) + + beego.Trace("testing", "TestGetMusicFolders", fmt.Sprintf("Code[%d]\n%s", w.Code, w.Body.String())) + + Convey("Subject: GetMusicFolders Endpoint\n", t, func() { + Convey("Status code should be 200", func() { + So(w.Code, ShouldEqual, 200) + }) + }) +} + diff --git a/tests/controllers/ping_test.go b/tests/controllers/ping_test.go index a33fe103f..d8ff0c8ec 100644 --- a/tests/controllers/ping_test.go +++ b/tests/controllers/ping_test.go @@ -10,8 +10,8 @@ import ( _ "github.com/deluan/gosonic/routers" "github.com/astaxie/beego" . "github.com/smartystreets/goconvey/convey" - "github.com/deluan/gosonic/responses" "fmt" + "github.com/deluan/gosonic/controllers/responses" ) func init() {