quintodrome/controllers/main_test.go

29 lines
704 B
Go
Raw Normal View History

package controllers_test
import (
2016-03-02 09:18:39 -09:00
"fmt"
"github.com/astaxie/beego"
_ "github.com/deluan/gosonic/conf"
"github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
"net/http"
"net/http/httptest"
2016-03-02 09:18:39 -09:00
"testing"
)
2016-02-27 15:28:29 -09:00
func TestErrorHandler(t *testing.T) {
tests.Init(t, false)
r, _ := http.NewRequest("GET", "/INVALID_PATH", nil)
w := httptest.NewRecorder()
beego.BeeApp.Handlers.ServeHTTP(w, r)
2016-02-27 15:28:29 -09:00
beego.Debug("testing", "TestErrorHandler", fmt.Sprintf("\nUrl: %s\nStatus Code: [%d]\n%s", r.URL, w.Code, w.Body.String()))
2016-02-27 15:28:29 -09:00
Convey("When requesting an non-existing URL\n", t, func() {
Convey("Then the status code should be 404", func() {
So(w.Code, ShouldEqual, 404)
})
})
2016-03-02 09:18:39 -09:00
}