github.com/zaquestion/lab@v0.25.1/cmd/issue_list_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_issueList(t *testing.T) {
    12  	t.Parallel()
    13  	repo := copyTestRepo(t)
    14  	cmd := exec.Command(labBinaryPath, "issue", "list")
    15  	cmd.Dir = repo
    16  
    17  	b, err := cmd.CombinedOutput()
    18  	if err != nil {
    19  		t.Fatal(err)
    20  	}
    21  
    22  	issues := strings.Split(string(b), "\n")
    23  	t.Log(issues)
    24  	require.Contains(t, issues, "#1 test issue for lab list")
    25  }
    26  
    27  func Test_issueListFlagLabel(t *testing.T) {
    28  	t.Parallel()
    29  	repo := copyTestRepo(t)
    30  	cmd := exec.Command(labBinaryPath, "issue", "list", "-l", "enhancement")
    31  	cmd.Dir = repo
    32  
    33  	b, err := cmd.CombinedOutput()
    34  	if err != nil {
    35  		t.Fatal(err)
    36  	}
    37  
    38  	issues := strings.Split(string(b), "\n")
    39  	t.Log(issues)
    40  	require.Contains(t, issues, "#3 test filter labels 1")
    41  }
    42  
    43  func Test_issueListStateClosed(t *testing.T) {
    44  	t.Parallel()
    45  	repo := copyTestRepo(t)
    46  	cmd := exec.Command(labBinaryPath, "issue", "list", "-s", "closed")
    47  	cmd.Dir = repo
    48  
    49  	b, err := cmd.CombinedOutput()
    50  	if err != nil {
    51  		t.Fatal(err)
    52  	}
    53  
    54  	issues := strings.Split(string(b), "\n")
    55  	t.Log(issues)
    56  	require.Contains(t, issues, "#4 test closed issue")
    57  }
    58  
    59  func Test_issueListFlagMilestone(t *testing.T) {
    60  	t.Parallel()
    61  	repo := copyTestRepo(t)
    62  	cmd := exec.Command(labBinaryPath, "issue", "list", "--milestone", "1.0")
    63  	cmd.Dir = repo
    64  
    65  	b, err := cmd.CombinedOutput()
    66  	if err != nil {
    67  		t.Fatal(err)
    68  	}
    69  
    70  	issues := strings.Split(string(b), "\n")
    71  	t.Log(issues)
    72  	require.Contains(t, issues, "#1 test issue for lab list")
    73  }
    74  
    75  func Test_issueListSearch(t *testing.T) {
    76  	t.Parallel()
    77  	repo := copyTestRepo(t)
    78  	cmd := exec.Command(labBinaryPath, "issue", "list", "filter labels")
    79  	cmd.Dir = repo
    80  
    81  	b, err := cmd.CombinedOutput()
    82  	if err != nil {
    83  		t.Fatal(err)
    84  	}
    85  
    86  	issues := strings.Split(string(b), "\n")
    87  	t.Log(issues)
    88  	require.Contains(t, issues, "#3 test filter labels 1")
    89  	require.NotContains(t, issues, "#1 test issue for lab list")
    90  }