-
-
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.
Add tests for the 'lab mr approve' and 'lab mr unapprove' command. Also, remove capital 'U' on unapproved message. Signed-off-by: Prarit Bhargava <[email protected]>
- Loading branch information
Showing
3 changed files
with
65 additions
and
32 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,64 @@ | ||
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_mrApproveSetup(t *testing.T) { | ||
t.Parallel() | ||
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, `Approved By: None`) | ||
} | ||
|
||
func Test_mrApprove(t *testing.T) { | ||
repo := copyTestRepo(t) | ||
orig := exec.Command(labBinaryPath, "mr", "approve", "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, `Merge Request #18 approved`) | ||
} | ||
|
||
func Test_mrUnapprove(t *testing.T) { | ||
repo := copyTestRepo(t) | ||
orig := exec.Command(labBinaryPath, "mr", "unapprove", "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, `Merge Request #18 unapproved`) | ||
} |
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
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