quintodrome/api/ping_test.go

32 lines
737 B
Go
Raw Normal View History

2016-02-27 14:42:08 -09:00
package api_test
2016-02-23 20:07:57 -09:00
import (
"encoding/xml"
"github.com/deluan/gosonic/api/responses"
2016-02-25 14:52:07 -09:00
. "github.com/smartystreets/goconvey/convey"
"testing"
2016-02-27 14:42:08 -09:00
"github.com/deluan/gosonic/tests"
2016-02-23 20:07:57 -09:00
)
func TestPing(t *testing.T) {
2016-02-27 14:42:08 -09:00
tests.Init(t, false)
2016-02-24 14:24:06 -09:00
_, w := Get(AddParams("/rest/ping.view"), "TestPing")
2016-02-23 20:07:57 -09:00
Convey("Subject: Ping Endpoint", t, func() {
Convey("Status code should be 200", func() {
2016-02-23 20:07:57 -09:00
So(w.Code, ShouldEqual, 200)
})
Convey("The result should not be empty", func() {
2016-02-23 20:07:57 -09:00
So(w.Body.Len(), ShouldBeGreaterThan, 0)
})
Convey("The result should be a valid ping response", func() {
v := responses.Subsonic{}
2016-02-23 20:29:27 -09:00
xml.Unmarshal(w.Body.Bytes(), &v)
So(v.Status, ShouldEqual, "ok")
So(v.Version, ShouldEqual, "1.0.0")
2016-02-23 20:07:57 -09:00
})
})
}