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
@@ -1,14 +1,13 @@
package api_test
import (
"encoding/xml"
"github.com/deluan/gosonic/tests"
. "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestGetLicense(t *testing.T) {
tests.Init(t, false)
Init(t, false)
_, w := Get(AddParams("/rest/getLicense.view"), "TestGetLicense")
@@ -17,10 +16,7 @@ func TestGetLicense(t *testing.T) {
So(w.Code, ShouldEqual, 200)
})
Convey("The license should always be valid", func() {
v := new(string)
err := xml.Unmarshal(w.Body.Bytes(), &v)
So(err, ShouldBeNil)
So(w.Body.String(), ShouldContainSubstring, `license valid="true"`)
So(UnindentJSON(w.Body.Bytes()), ShouldContainSubstring, `"license":{"valid":true}`)
})
})