Use mode in all tests

This commit is contained in:
Jannis Mattheis
2018-03-15 21:54:06 +01:00
committed by Jannis Mattheis
parent ff73e0b5e9
commit 9e49849039
9 changed files with 23 additions and 14 deletions

View File

@@ -10,10 +10,11 @@ import (
"github.com/gin-gonic/gin"
"github.com/gotify/server/model"
"github.com/stretchr/testify/assert"
"github.com/gotify/server/mode"
)
func TestDefaultErrorInternal(t *testing.T) {
gin.SetMode(gin.TestMode)
mode.Set(mode.TestDev)
rec := httptest.NewRecorder()
ctx, _ := gin.CreateTestContext(rec)
ctx.AbortWithError(500, errors.New("something went wrong"))
@@ -24,7 +25,7 @@ func TestDefaultErrorInternal(t *testing.T) {
}
func TestBindingErrorDefault(t *testing.T) {
gin.SetMode(gin.TestMode)
mode.Set(mode.TestDev)
rec := httptest.NewRecorder()
ctx, _ := gin.CreateTestContext(rec)
ctx.AbortWithError(400, errors.New("you need todo something")).SetType(gin.ErrorTypeBind)
@@ -35,7 +36,7 @@ func TestBindingErrorDefault(t *testing.T) {
}
func TestDefaultErrorBadRequest(t *testing.T) {
gin.SetMode(gin.TestMode)
mode.Set(mode.TestDev)
rec := httptest.NewRecorder()
ctx, _ := gin.CreateTestContext(rec)
ctx.AbortWithError(400, errors.New("you need todo something"))
@@ -51,7 +52,7 @@ type testValidate struct {
}
func TestValidationError(t *testing.T) {
gin.SetMode(gin.TestMode)
mode.Set(mode.TestDev)
rec := httptest.NewRecorder()
ctx, _ := gin.CreateTestContext(rec)
ctx.Request = httptest.NewRequest("GET", "/uri", nil)