navidrome/api/api_test.go

30 lines
702 B
Go
Raw Normal View History

2016-02-27 18:42:08 -05:00
package api_test
2016-02-24 18:24:06 -05:00
import (
"fmt"
"github.com/astaxie/beego"
"net/http"
2016-02-25 18:52:07 -05:00
"net/http/httptest"
2016-03-01 09:23:40 -05:00
_ "github.com/deluan/gosonic/conf"
2016-02-24 18:24:06 -05:00
)
const (
2016-02-27 18:42:08 -05:00
testUser = "deluan"
testPassword = "wordpass"
2016-02-27 18:42:08 -05:00
testClient = "test"
testVersion = "1.0.0"
)
func AddParams(url string) string {
return fmt.Sprintf("%s?u=%s&p=%s&c=%s&v=%s", url, testUser, testPassword, testClient, testVersion)
}
2016-02-24 18:33:13 -05:00
func Get(url string, testCase string) (*http.Request, *httptest.ResponseRecorder) {
2016-02-24 18:24:06 -05:00
r, _ := http.NewRequest("GET", url, nil)
w := httptest.NewRecorder()
beego.BeeApp.Handlers.ServeHTTP(w, r)
2016-02-25 11:14:16 -05:00
beego.Debug("testing", testCase, fmt.Sprintf("\nUrl: %s\nStatus Code: [%d]\n%s", r.URL, w.Code, w.Body.String()))
2016-02-24 18:24:06 -05:00
return r, w
}