cleanup(shellx): do not directly depend on apex/log (#357)
This commit is contained in:
parent
944d3c53fa
commit
39aec6677d
8 changed files with 52 additions and 39 deletions
|
|
@ -1,12 +1,16 @@
|
|||
package shellx
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/apex/log"
|
||||
)
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
if err := Run("whoami"); err != nil {
|
||||
if err := Run(log.Log, "whoami"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := Run("./nonexistent/command"); err == nil {
|
||||
if err := Run(log.Log, "./nonexistent/command"); err == nil {
|
||||
t.Fatal("expected an error here")
|
||||
}
|
||||
}
|
||||
|
|
@ -22,22 +26,22 @@ func TestRunQuiet(t *testing.T) {
|
|||
|
||||
func TestRunCommandline(t *testing.T) {
|
||||
t.Run("when the command does not parse", func(t *testing.T) {
|
||||
if err := RunCommandline(`"foobar`); err == nil {
|
||||
if err := RunCommandline(log.Log, `"foobar`); err == nil {
|
||||
t.Fatal("expected an error here")
|
||||
}
|
||||
})
|
||||
t.Run("when we have no arguments", func(t *testing.T) {
|
||||
if err := RunCommandline(""); err == nil {
|
||||
if err := RunCommandline(log.Log, ""); err == nil {
|
||||
t.Fatal("expected an error here")
|
||||
}
|
||||
})
|
||||
t.Run("when we have a single argument", func(t *testing.T) {
|
||||
if err := RunCommandline("ls"); err != nil {
|
||||
if err := RunCommandline(log.Log, "ls"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
t.Run("when we have more than one argument", func(t *testing.T) {
|
||||
if err := RunCommandline("ls ."); err != nil {
|
||||
if err := RunCommandline(log.Log, "ls ."); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue