wings/api/handlers_test.go
Jakob Schrettenbrunner 059ea8a047 add all old routes and handlers
add html index page when not authenticated
fixed auth's handling of empty permissions
2017-08-02 22:02:34 +02:00

47 lines
977 B
Go

package api
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
)
func TestHandleGetIndex(t *testing.T) {
router := gin.New()
recorder := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/", nil)
router.GET("/", handleGetIndex)
router.ServeHTTP(recorder, req)
assert.Equal(t, http.StatusOK, recorder.Code)
}
func TestHandlePutConfig(t *testing.T) {
router := gin.New()
recorder := httptest.NewRecorder()
req, _ := http.NewRequest("PUT", "/", strings.NewReader("{}"))
router.PUT("/", handlePutConfig)
router.ServeHTTP(recorder, req)
assert.Equal(t, http.StatusOK, recorder.Code)
}
func TestHandlePatchConfig(t *testing.T) {
router := gin.New()
recorder := httptest.NewRecorder()
req, _ := http.NewRequest("PATCH", "/", strings.NewReader("{}"))
router.PATCH("/", handlePatchConfig)
router.ServeHTTP(recorder, req)
assert.Equal(t, http.StatusOK, recorder.Code)
}