Skip to content

Commit

Permalink
mr_test: Fix cleanupMR()
Browse files Browse the repository at this point in the history
The cleanupMR() function doesn't work when calling "sh -c".  It should
just call the executables directly.

Fix the cleanupMR() to call executables directly.

Signed-off-by: Prarit Bhargava <[email protected]>
  • Loading branch information
prarit committed Mar 25, 2021
1 parent 645c7e8 commit fc1356f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cmd/mr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,20 @@ func closeMR(t *testing.T, targetRepo string, cmdDir string, mrID string) {
}

func cleanupMR(t *testing.T, targetRepo string, cmdDir string, MRtitle string) {
openMRcmd := exec.Command("sh", "-c", fmt.Sprintf("%s mr list %s | grep -m1 \"%s\" | cut -c2- | awk '{print $1}'", labBinaryPath, targetRepo, MRtitle))
openMRcmd := exec.Command(labBinaryPath, "mr", "list", targetRepo, MRtitle)
openMRcmd.Dir = cmdDir
openMRstr, err := openMRcmd.CombinedOutput()
openMRout, err := openMRcmd.CombinedOutput()
if err != nil {
t.Log(string(openMRstr))
t.Fatal(err)
t.Log(string(openMRout))
}

openMR, err := strconv.Atoi(strings.TrimSpace(string(openMRstr)))
// find MR number
s := strings.Split(string(openMRout), " ")
openMRstr := s[0]
// strip off "!"
openMRstr = openMRstr[1:]

openMR, err := strconv.Atoi(openMRstr)
if err != nil {
t.Log(string(openMRstr))
return
Expand Down Expand Up @@ -120,6 +125,7 @@ func Test_mrCmd_MR_description_and_options(t *testing.T) {
)
t.Run("prepare", func(t *testing.T) {
cleanupMR(t, "lab-testing", repo, "Fancy Description")
cleanupMR(t, "lab-testing", repo, "Updated Description")
})
t.Run("create MR from file", func(t *testing.T) {
git := exec.Command("git", "checkout", "mrtest")
Expand Down

0 comments on commit fc1356f

Please sign in to comment.