github.com/zaquestion/lab@v0.25.1/cmd/issue_show_test.go (about)

     1  package cmd
     2  
     3  import (
     4  	"os/exec"
     5  	"testing"
     6  
     7  	"github.com/acarl005/stripansi"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func Test_issueShow(t *testing.T) {
    12  	t.Parallel()
    13  	repo := copyTestRepo(t)
    14  	cmd := exec.Command(labBinaryPath, "issue", "show", "1", "--comments")
    15  	cmd.Dir = repo
    16  
    17  	b, err := cmd.CombinedOutput()
    18  	if err != nil {
    19  		t.Log(string(b))
    20  		t.Error(err)
    21  	}
    22  
    23  	out := string(b)
    24  	require.Contains(t, out, `#1 test issue for lab list
    25  ===================================
    26  
    27  -----------------------------------
    28  Project: zaquestion/test
    29  Status: Open
    30  Assignees: zaquestion, lab-testing
    31  Author: lab-testing
    32  Milestone: 1.0
    33  Due Date: 2018-01-01 00:00:00 +0000 UTC
    34  Time Stats: Estimated 40h, Spent 8h
    35  Labels: bug
    36  Related MRs: 1
    37  MRs that will close this Issue: 
    38  Subscribed: No
    39  WebURL: https://gitlab.com/zaquestion/test/-/issues/1
    40  `)
    41  
    42  	require.Contains(t, string(b), `commented at`)
    43  }
    44  
    45  func Test_issueShow_updated_comments(t *testing.T) {
    46  	t.Parallel()
    47  	repo := copyTestRepo(t)
    48  	cmd := exec.Command(labBinaryPath, "issue", "show", "8", "--comments")
    49  	cmd.Dir = repo
    50  
    51  	b, err := cmd.CombinedOutput()
    52  	if err != nil {
    53  		t.Log(string(b))
    54  		t.Error(err)
    55  	}
    56  	out := stripansi.Strip(string(b))
    57  
    58  	require.Contains(t, string(out), `updated comment at`)
    59  }