refactoring process management: no more orphan processes and quicker chrome startup

This commit is contained in:
Julien Neuhart
2019-10-02 10:38:47 +02:00
parent c47dc5ecdb
commit 7ac104c3c6
8 changed files with 187 additions and 137 deletions

View File

@@ -5,6 +5,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/thecodingmachine/gotenberg/internal/pkg/xcontext"
"github.com/thecodingmachine/gotenberg/test"
)
@@ -37,3 +38,16 @@ func TestCommandContext(t *testing.T) {
LogBeforeExecute(logger, cmd)
assert.Nil(t, err)
}
func TestRun(t *testing.T) {
logger := test.DebugLogger()
// should run without issue.
err := Run(context.Background(), logger, "echo", "Hello", "World")
assert.Nil(t, err)
// should not be OK as context.Context
// should timeout.
ctx, cancel := xcontext.WithTimeout(logger, 0)
defer cancel()
err = Run(ctx, logger, "echo", "Hello", "World")
assert.NotNil(t, err)
}