mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-08 16:42:15 +01:00
40 lines
1.1 KiB
Go
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)
|
|
}
|