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

     1  package cmd
     2  
     3  import (
     4  	"os/exec"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func Test_issueCloseReopen(t *testing.T) {
    11  	tests := []struct {
    12  		desc     string
    13  		opt      string
    14  		expected string
    15  	}{
    16  		{
    17  			desc:     "reopen-open",
    18  			opt:      "reopen",
    19  			expected: "issue not closed",
    20  		},
    21  		{
    22  			desc:     "close-open",
    23  			opt:      "close",
    24  			expected: "Issue #1 closed",
    25  		},
    26  		{
    27  			desc:     "close-closed",
    28  			opt:      "close",
    29  			expected: "issue already closed",
    30  		},
    31  		{
    32  			desc:     "reopen-closed",
    33  			opt:      "reopen",
    34  			expected: "Issue #1 reopened",
    35  		},
    36  	}
    37  
    38  	repo := copyTestRepo(t)
    39  	for _, test := range tests {
    40  		test := test
    41  		t.Run(test.desc, func(t *testing.T) {
    42  			cmd := exec.Command(labBinaryPath, "issue", test.opt, "1")
    43  			cmd.Dir = repo
    44  
    45  			b, err := cmd.CombinedOutput()
    46  			if err != nil {
    47  				t.Log(string(b))
    48  			}
    49  
    50  			out := string(b)
    51  			require.Contains(t, out, test.expected)
    52  		})
    53  	}
    54  }