adding ability to write a log file with all output from collector. Executing commands will now log be logged (and when debug is enabled, their output's are also logged).
This commit is contained in:
@@ -2,6 +2,7 @@ package common_test
|
||||
|
||||
import (
|
||||
"github.com/analogj/scrutiny/collector/pkg/common"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/require"
|
||||
"os/exec"
|
||||
"testing"
|
||||
@@ -13,7 +14,7 @@ func TestExecCmd(t *testing.T) {
|
||||
//setup
|
||||
|
||||
//test
|
||||
result, err := common.ExecCmd("echo", []string{"hello world"}, "", nil)
|
||||
result, err := common.ExecCmd(logrus.WithField("exec", "test"), "echo", []string{"hello world"}, "", nil)
|
||||
|
||||
//assert
|
||||
require.NoError(t, err)
|
||||
@@ -26,7 +27,7 @@ func TestExecCmd_Date(t *testing.T) {
|
||||
//setup
|
||||
|
||||
//test
|
||||
_, err := common.ExecCmd("date", []string{}, "", nil)
|
||||
_, err := common.ExecCmd(logrus.WithField("exec", "test"), "date", []string{}, "", nil)
|
||||
|
||||
//assert
|
||||
require.NoError(t, err)
|
||||
@@ -56,7 +57,7 @@ func TestExecCmd_InvalidCommand(t *testing.T) {
|
||||
//setup
|
||||
|
||||
//test
|
||||
_, err := common.ExecCmd("invalid_binary", []string{}, "", nil)
|
||||
_, err := common.ExecCmd(logrus.WithField("exec", "test"), "invalid_binary", []string{}, "", nil)
|
||||
|
||||
//assert
|
||||
_, castOk := err.(*exec.ExitError)
|
||||
|
||||
Reference in New Issue
Block a user