Files
gotenberg/internal/pkg/xexec/xexec_test.go
2019-07-24 14:56:12 +02:00

40 lines
1.1 KiB
Go

package xexec
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/thecodingmachine/gotenberg/test"
)
func TestCommand(t *testing.T) {
logger := test.DebugLogger()
// should pipe command output as
// xlog.Logger has a xlog.DebugLevel.
cmd, err := Command(logger, "echo", "Hello", "World")
assert.Nil(t, err)
LogBeforeExecute(logger, cmd)
// should not pipe command output as
// xlog.Logger has a xlog.InfoLevel.
logger = test.InfoLogger()
cmd, err = Command(logger, "echo", "Hello", "World")
LogBeforeExecute(logger, cmd)
assert.Nil(t, err)
}
func TestCommandContext(t *testing.T) {
logger := test.DebugLogger()
// should pipe command output as
// xlog.Logger has a xlog.DebugLevel.
cmd, err := CommandContext(context.Background(), logger, "echo", "Hello", "World")
assert.Nil(t, err)
LogBeforeExecute(logger, cmd)
// should not pipe command output as
// xlog.Logger has a xlog.InfoLevel.
logger = test.InfoLogger()
cmd, err = CommandContext(context.Background(), logger, "echo", "Hello", "World")
LogBeforeExecute(logger, cmd)
assert.Nil(t, err)
}