mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-16 20:32:13 +01:00
fixing tests
This commit is contained in:
@@ -45,8 +45,7 @@ RUN mkdir -p /usr/share/man/man1mkdir -p /usr/share/man/man1 &&\
|
|||||||
|
|
||||||
ENV UNO_URL=https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv
|
ENV UNO_URL=https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv
|
||||||
|
|
||||||
RUN apt-get install -y python3 &&\
|
RUN curl -Ls $UNO_URL -o /usr/bin/unoconv &&\
|
||||||
curl -Ls $UNO_URL -o /usr/bin/unoconv &&\
|
|
||||||
chmod +x /usr/bin/unoconv &&\
|
chmod +x /usr/bin/unoconv &&\
|
||||||
ln -s /usr/bin/python3 /usr/bin/python &&\
|
ln -s /usr/bin/python3 /usr/bin/python &&\
|
||||||
unoconv --version
|
unoconv --version
|
||||||
|
|||||||
@@ -9,10 +9,8 @@ if [ "$CURRENT_USER" != "gotenberg" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start the PM2 processes
|
# Start Google Chrome headless.
|
||||||
# (Google Chrome headless & unoconv listener).
|
go run test/cmd/chrome.go
|
||||||
# TODO just start chrome
|
|
||||||
go run github.com/thecodingmachine/gotenberg/test/cmd/pm2
|
|
||||||
|
|
||||||
# Run our tests.
|
# Run our tests.
|
||||||
if [ "$CODE_COVERAGE" = "1" ]; then
|
if [ "$CODE_COVERAGE" = "1" ]; then
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
@@ -23,18 +22,6 @@ func TestPingHandler(t *testing.T) {
|
|||||||
srv = New(config)
|
srv = New(config)
|
||||||
req := httptest.NewRequest(http.MethodGet, pingEndpoint, nil)
|
req := httptest.NewRequest(http.MethodGet, pingEndpoint, nil)
|
||||||
test.AssertStatusCode(t, http.StatusOK, srv, req)
|
test.AssertStatusCode(t, http.StatusOK, srv, req)
|
||||||
// should returns a JSON as
|
|
||||||
// LOG_LEVEL is "DEBUG".
|
|
||||||
os.Setenv(conf.LogLevelEnvVar, "DEBUG")
|
|
||||||
config, err := conf.FromEnv()
|
|
||||||
assert.Nil(t, err)
|
|
||||||
srv = New(config)
|
|
||||||
req = httptest.NewRequest(http.MethodGet, pingEndpoint, nil)
|
|
||||||
rec := httptest.NewRecorder()
|
|
||||||
srv.ServeHTTP(rec, req)
|
|
||||||
assert.Equal(t, "application/json; charset=UTF-8", rec.Header().Get("Content-type"))
|
|
||||||
assert.Equal(t, http.StatusOK, rec.Code)
|
|
||||||
os.Unsetenv(conf.LogLevelEnvVar)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMergeHandler(t *testing.T) {
|
func TestMergeHandler(t *testing.T) {
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
// Package chrome helps starting
|
||||||
|
// Google Chrome headless in background.
|
||||||
package chrome
|
package chrome
|
||||||
|
|||||||
23
test/cmd/chrome.go
Normal file
23
test/cmd/chrome.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/thecodingmachine/gotenberg/internal/pkg/chrome"
|
||||||
|
"github.com/thecodingmachine/gotenberg/internal/pkg/conf"
|
||||||
|
"github.com/thecodingmachine/gotenberg/internal/pkg/xlog"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
const op string = "main"
|
||||||
|
config, err := conf.FromEnv()
|
||||||
|
systemLogger := xlog.New(config.LogLevel(), "system")
|
||||||
|
if err != nil {
|
||||||
|
systemLogger.FatalOp(op, err)
|
||||||
|
}
|
||||||
|
// start Google Chrome.
|
||||||
|
_, err = chrome.Start(context.Background(), systemLogger)
|
||||||
|
if err != nil {
|
||||||
|
systemLogger.FatalOp(op, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user