From 91e15c8c0544aa2e3da700abbf79d38c68d9401a Mon Sep 17 00:00:00 2001 From: dylanhitt Date: Mon, 29 Aug 2022 11:30:34 -0400 Subject: [PATCH] Migrate WithCustomerBaseCommand test to linux test suite for test coverage purposes --- command_darwin_test.go | 14 -------------- command_linux_test.go | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/command_darwin_test.go b/command_darwin_test.go index a7b22ac..e107fc9 100644 --- a/command_darwin_test.go +++ b/command_darwin_test.go @@ -1,26 +1,12 @@ package cmd import ( - "os/exec" "testing" "time" "github.com/stretchr/testify/assert" ) -func TestCommand_WithCustomBaseCommand(t *testing.T) { - cmd := NewCommand( - "echo $0", - WithCustomBaseCommand(exec.Command("/bin/bash", "-c")), - ) - - err := cmd.Execute() - assert.Nil(t, err) - // on darwin we use /bin/sh by default test if we're using bash - assert.NotEqual(t, "/bin/sh\n", cmd.Stdout()) - assert.Equal(t, "/bin/bash\n", cmd.Stdout()) -} - func TestCommand_ExecuteStderr(t *testing.T) { cmd := NewCommand(">&2 echo hello") diff --git a/command_linux_test.go b/command_linux_test.go index decee95..0649bd6 100644 --- a/command_linux_test.go +++ b/command_linux_test.go @@ -5,6 +5,7 @@ import ( "context" "io/ioutil" "os" + "os/exec" "strings" "testing" "time" @@ -157,3 +158,16 @@ func TestCommand_WithContext(t *testing.T) { assert.NotNil(t, err) assert.Equal(t, "context deadline exceeded", err.Error()) } + +func TestCommand_WithCustomBaseCommand(t *testing.T) { + cmd := NewCommand( + "echo $0", + WithCustomBaseCommand(exec.Command("/bin/bash", "-c")), + ) + + err := cmd.Execute() + assert.Nil(t, err) + // on darwin we use /bin/sh by default test if we're using bash + assert.NotEqual(t, "/bin/sh\n", cmd.Stdout()) + assert.Equal(t, "/bin/bash\n", cmd.Stdout()) +}