Small fixes to response marshaling, introduced tests for response formats

This commit is contained in:
Deluan
2016-03-02 17:23:26 -05:00
parent b9fb5eb7ca
commit dde130e84e
10 changed files with 154 additions and 41 deletions
+3 -7
View File
@@ -3,13 +3,12 @@ package api_test
import (
"testing"
"encoding/xml"
"github.com/deluan/gosonic/tests"
. "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
)
func TestGetMusicFolders(t *testing.T) {
tests.Init(t, false)
Init(t, false)
_, w := Get(AddParams("/rest/getMusicFolders.view"), "TestGetMusicFolders")
@@ -18,10 +17,7 @@ func TestGetMusicFolders(t *testing.T) {
So(w.Code, ShouldEqual, 200)
})
Convey("The response should include the default folder", func() {
v := new(string)
err := xml.Unmarshal(w.Body.Bytes(), &v)
So(err, ShouldBeNil)
So(w.Body.String(), ShouldContainSubstring, `musicFolder id="0" name="iTunes Library"`)
So(UnindentJSON(w.Body.Bytes()), ShouldContainSubstring, `{"musicFolder":[{"id":"0","name":"iTunes Library"}]}`)
})
})
}