github.com/x-motemen/ghq@v1.6.1/cmdutil/run_test.go (about)

     1  package cmdutil
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  	"testing"
     7  )
     8  
     9  func TestRunInDirSilently(t *testing.T) {
    10  	err := RunInDirSilently(".", "/path/to/unknown")
    11  	expect := "/path/to/unknown: "
    12  	if !strings.HasPrefix(fmt.Sprintf("%s", err), expect) {
    13  		t.Errorf("error message should have prefix %q, but: %q", expect, err)
    14  	}
    15  }
    16  
    17  func TestRun(t *testing.T) {
    18  	err := Run("echo")
    19  	if err != nil {
    20  		t.Errorf("error should be nil but: %s", err)
    21  	}
    22  }
    23  
    24  func TestRunInDir(t *testing.T) {
    25  	err := RunInDir(".", "echo")
    26  	if err != nil {
    27  		t.Errorf("error should be nil but: %s", err)
    28  	}
    29  }
    30  
    31  func TestRunSilently(t *testing.T) {
    32  	err := RunSilently("echo")
    33  	if err != nil {
    34  		t.Errorf("error should be nil but: %s", err)
    35  	}
    36  }