adding xhttp package tests for checking that endpoints return a correct status code according if google chrome and/or unoconv are disabled in the configuration

This commit is contained in:
Julien Neuhart
2019-08-19 17:21:30 +02:00
parent 08c97f280f
commit daf7cb9d6b
5 changed files with 241 additions and 90 deletions

17
test/http.go Normal file
View File

@@ -0,0 +1,17 @@
package test
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
// AssertStatusCode checks if the given request
// returns the expected status code.
func AssertStatusCode(t *testing.T, expectedStatusCode int, srv http.Handler, req *http.Request) {
rec := httptest.NewRecorder()
srv.ServeHTTP(rec, req)
assert.Equal(t, expectedStatusCode, rec.Code)
}