adding PM2 processes details as response of ping endpoint if LOG_LEVEL=DEBUG

This commit is contained in:
Julien Neuhart
2019-08-20 15:23:02 +02:00
parent fc27f6b3f0
commit 95c6ecb724
4 changed files with 131 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ import (
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/labstack/echo/v4"
@@ -15,7 +16,26 @@ import (
"github.com/thecodingmachine/gotenberg/test"
)
// TODO test ping handler
func TestPingHandler(t *testing.T) {
// should return 200.
config := conf.DefaultConfig()
srv := New(config)
srv = New(config)
req := httptest.NewRequest(http.MethodGet, pingEndpoint, nil)
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) {
config := conf.DefaultConfig()