github.com/zaquestion/lab@v0.25.1/cmd/issue_subscribe_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_issueSubscribeSetup(t *testing.T) {
    12  	repo := copyTestRepo(t)
    13  	orig := exec.Command(labBinaryPath, "issue", "show", "1")
    14  	orig.Dir = repo
    15  
    16  	b, err := orig.CombinedOutput()
    17  	if err != nil {
    18  		t.Log(string(b))
    19  		t.Error(err)
    20  	}
    21  
    22  	origOutput := string(b)
    23  	origOutput = stripansi.Strip(origOutput)
    24  
    25  	require.Contains(t, origOutput, `Subscribed: No`)
    26  }
    27  
    28  func Test_issueSubscribe(t *testing.T) {
    29  	repo := copyTestRepo(t)
    30  	orig := exec.Command(labBinaryPath, "issue", "subscribe", "1")
    31  	orig.Dir = repo
    32  
    33  	b, err := orig.CombinedOutput()
    34  	if err != nil {
    35  		t.Log(string(b))
    36  		t.Error(err)
    37  	}
    38  
    39  	origOutput := string(b)
    40  	origOutput = stripansi.Strip(origOutput)
    41  
    42  	require.Contains(t, origOutput, `Subscribed to issue #1`)
    43  }
    44  
    45  func Test_issueUnsubscribe(t *testing.T) {
    46  	repo := copyTestRepo(t)
    47  	orig := exec.Command(labBinaryPath, "issue", "unsubscribe", "1")
    48  	orig.Dir = repo
    49  
    50  	b, err := orig.CombinedOutput()
    51  	if err != nil {
    52  		t.Log(string(b))
    53  		t.Error(err)
    54  	}
    55  
    56  	origOutput := string(b)
    57  	origOutput = stripansi.Strip(origOutput)
    58  
    59  	require.Contains(t, origOutput, `Unsubscribed from issue #1`)
    60  }