Skip to content

Commit

Permalink
Migrate WithCustomerBaseCommand test to linux test suite for test cov…
Browse files Browse the repository at this point in the history
…erage purposes
  • Loading branch information
dylanhitt committed Aug 29, 2022
1 parent 2016981 commit 91e15c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 0 additions & 14 deletions command_darwin_test.go
Original file line number Diff line number Diff line change
@@ -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")

Expand Down
14 changes: 14 additions & 0 deletions command_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"io/ioutil"
"os"
"os/exec"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -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())
}

0 comments on commit 91e15c8

Please sign in to comment.