mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-16 04:12:16 +01:00
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:
17
test/http.go
Normal file
17
test/http.go
Normal 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)
|
||||
}
|
||||
@@ -2,8 +2,6 @@ package test
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -11,14 +9,6 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// AssertDirectoryEmpty checks if given directory
|
||||
// is empty.
|
||||
func AssertDirectoryEmpty(t *testing.T, directory string) {
|
||||
|
||||
Reference in New Issue
Block a user