github.com/nkprince007/lab@v0.6.2-0.20171218071646-19d68b56f403/cmd/snippetList_test.go (about)

     1  package cmd
     2  
     3  import (
     4  	"os/exec"
     5  	"strings"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func Test_snippetList(t *testing.T) {
    12  	repo := copyTestRepo(t)
    13  	cmd := exec.Command("../lab_bin", "snippet", "list", "lab-testing")
    14  	cmd.Dir = repo
    15  
    16  	b, err := cmd.CombinedOutput()
    17  	if err != nil {
    18  		t.Log(string(b))
    19  		t.Fatal(err)
    20  	}
    21  
    22  	snips := strings.Split(string(b), "\n")
    23  	t.Log(snips)
    24  	require.Regexp(t, `#\d+ snippet title`, snips[0])
    25  }
    26  
    27  func Test_snippetList_Global(t *testing.T) {
    28  	repo := copyTestRepo(t)
    29  	cmd := exec.Command("../lab_bin", "snippet", "list", "-g")
    30  	cmd.Dir = repo
    31  
    32  	b, err := cmd.CombinedOutput()
    33  	if err != nil {
    34  		t.Log(string(b))
    35  		t.Fatal(err)
    36  	}
    37  
    38  	snips := strings.Split(string(b), "\n")
    39  	t.Log(snips)
    40  	require.Regexp(t, `#\d+ personal snippet title`, snips[0])
    41  }