2016-02-27 14:42:08 -09:00
|
|
|
package api_test
|
2016-02-23 20:07:57 -09:00
|
|
|
|
|
|
|
|
import (
|
2016-03-02 20:46:23 -09:00
|
|
|
"encoding/json"
|
2016-03-09 06:22:10 -09:00
|
|
|
"testing"
|
|
|
|
|
|
2016-02-25 12:31:06 -09:00
|
|
|
"github.com/deluan/gosonic/api/responses"
|
2016-03-02 13:23:26 -09:00
|
|
|
. "github.com/deluan/gosonic/tests"
|
2016-02-25 14:52:07 -09:00
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
2016-02-23 20:07:57 -09:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestPing(t *testing.T) {
|
2016-03-02 13:23:26 -09:00
|
|
|
Init(t, false)
|
2016-02-27 14:42:08 -09:00
|
|
|
|
2016-02-24 14:24:06 -09:00
|
|
|
_, w := Get(AddParams("/rest/ping.view"), "TestPing")
|
2016-02-23 20:07:57 -09:00
|
|
|
|
2016-03-01 05:17:28 -09:00
|
|
|
Convey("Subject: Ping Endpoint", t, func() {
|
2016-02-24 07:29:26 -09:00
|
|
|
Convey("Status code should be 200", func() {
|
2016-02-23 20:07:57 -09:00
|
|
|
So(w.Code, ShouldEqual, 200)
|
|
|
|
|
})
|
2016-02-24 07:29:26 -09:00
|
|
|
Convey("The result should not be empty", func() {
|
2016-02-23 20:07:57 -09:00
|
|
|
So(w.Body.Len(), ShouldBeGreaterThan, 0)
|
|
|
|
|
})
|
2016-02-24 07:29:26 -09:00
|
|
|
Convey("The result should be a valid ping response", func() {
|
2016-03-02 13:23:26 -09:00
|
|
|
v := responses.JsonWrapper{}
|
|
|
|
|
err := json.Unmarshal(w.Body.Bytes(), &v)
|
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
So(v.Subsonic.Status, ShouldEqual, "ok")
|
2016-03-11 11:08:37 -09:00
|
|
|
So(v.Subsonic.Version, ShouldEqual, "1.5.0")
|
2016-02-23 20:07:57 -09:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
2016-03-09 06:22:10 -09:00
|
|
|
func TestGetLicense(t *testing.T) {
|
|
|
|
|
Init(t, false)
|
|
|
|
|
|
|
|
|
|
_, w := Get(AddParams("/rest/getLicense.view"), "TestGetLicense")
|
|
|
|
|
|
|
|
|
|
Convey("Subject: GetLicense Endpoint", t, func() {
|
|
|
|
|
Convey("Status code should be 200", func() {
|
|
|
|
|
So(w.Code, ShouldEqual, 200)
|
|
|
|
|
})
|
|
|
|
|
Convey("The license should always be valid", func() {
|
|
|
|
|
So(UnindentJSON(w.Body.Bytes()), ShouldContainSubstring, `"license":{"valid":true}`)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|