-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mr/issue: Test (un)subscribe commands
- Loading branch information
Showing
2 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package cmd | ||
|
||
import ( | ||
"os/exec" | ||
"testing" | ||
|
||
"github.com/acarl005/stripansi" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_issueSubscribeSetup(t *testing.T) { | ||
repo := copyTestRepo(t) | ||
orig := exec.Command(labBinaryPath, "issue", "show", "1") | ||
orig.Dir = repo | ||
|
||
b, err := orig.CombinedOutput() | ||
if err != nil { | ||
t.Log(string(b)) | ||
t.Error(err) | ||
} | ||
|
||
origOutput := string(b) | ||
origOutput = stripansi.Strip(origOutput) | ||
|
||
require.Contains(t, origOutput, `Subscribed: No`) | ||
} | ||
|
||
func Test_issueSubscribe(t *testing.T) { | ||
repo := copyTestRepo(t) | ||
orig := exec.Command(labBinaryPath, "issue", "subscribe", "1") | ||
orig.Dir = repo | ||
|
||
b, err := orig.CombinedOutput() | ||
if err != nil { | ||
t.Log(string(b)) | ||
t.Error(err) | ||
} | ||
|
||
origOutput := string(b) | ||
origOutput = stripansi.Strip(origOutput) | ||
|
||
require.Contains(t, origOutput, `Subscribed to issue #1`) | ||
} | ||
|
||
func Test_issueUnsubscribe(t *testing.T) { | ||
repo := copyTestRepo(t) | ||
orig := exec.Command(labBinaryPath, "issue", "unsubscribe", "1") | ||
orig.Dir = repo | ||
|
||
b, err := orig.CombinedOutput() | ||
if err != nil { | ||
t.Log(string(b)) | ||
t.Error(err) | ||
} | ||
|
||
origOutput := string(b) | ||
origOutput = stripansi.Strip(origOutput) | ||
|
||
require.Contains(t, origOutput, `Unsubscribed from issue #1`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package cmd | ||
|
||
import ( | ||
"os/exec" | ||
"testing" | ||
|
||
"github.com/acarl005/stripansi" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// https://gitlab.com/zaquestion/test/-/merge_requests/18 was opened for these | ||
// tests | ||
|
||
func Test_mrSubscribeSetup(t *testing.T) { | ||
repo := copyTestRepo(t) | ||
orig := exec.Command(labBinaryPath, "mr", "show", "18") | ||
orig.Dir = repo | ||
|
||
b, err := orig.CombinedOutput() | ||
if err != nil { | ||
t.Log(string(b)) | ||
t.Error(err) | ||
} | ||
|
||
origOutput := string(b) | ||
origOutput = stripansi.Strip(origOutput) | ||
|
||
require.Contains(t, origOutput, `Subscribed: No`) | ||
} | ||
|
||
func Test_mrSubscribe(t *testing.T) { | ||
repo := copyTestRepo(t) | ||
orig := exec.Command(labBinaryPath, "mr", "subscribe", "18") | ||
orig.Dir = repo | ||
|
||
b, err := orig.CombinedOutput() | ||
if err != nil { | ||
t.Log(string(b)) | ||
t.Error(err) | ||
} | ||
|
||
origOutput := string(b) | ||
origOutput = stripansi.Strip(origOutput) | ||
|
||
require.Contains(t, origOutput, `Subscribed to merge request !18`) | ||
} | ||
|
||
func Test_mrUnsubscribe(t *testing.T) { | ||
repo := copyTestRepo(t) | ||
orig := exec.Command(labBinaryPath, "mr", "unsubscribe", "18") | ||
orig.Dir = repo | ||
|
||
b, err := orig.CombinedOutput() | ||
if err != nil { | ||
t.Log(string(b)) | ||
t.Error(err) | ||
} | ||
|
||
origOutput := string(b) | ||
origOutput = stripansi.Strip(origOutput) | ||
|
||
require.Contains(t, origOutput, `Unsubscribed from merge request !18`) | ||
} |