github.com/zaquestion/lab@v0.25.1/cmd/mr_approve_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 // https://gitlab.com/zaquestion/test/-/merge_requests/18 was opened for these 12 // tests 13 14 func Test_mrApproveSetup(t *testing.T) { 15 repo := copyTestRepo(t) 16 orig := exec.Command(labBinaryPath, "mr", "show", "18") 17 orig.Dir = repo 18 19 b, err := orig.CombinedOutput() 20 if err != nil { 21 t.Log(string(b)) 22 t.Error(err) 23 } 24 25 origOutput := string(b) 26 origOutput = stripansi.Strip(origOutput) 27 28 require.Contains(t, origOutput, `Approved By: None`) 29 } 30 31 func Test_mrApprove(t *testing.T) { 32 repo := copyTestRepo(t) 33 orig := exec.Command(labBinaryPath, "mr", "approve", "18") 34 orig.Dir = repo 35 36 b, err := orig.CombinedOutput() 37 if err != nil { 38 t.Log(string(b)) 39 t.Error(err) 40 } 41 42 origOutput := string(b) 43 origOutput = stripansi.Strip(origOutput) 44 45 require.Contains(t, origOutput, `Merge Request !18 approved`) 46 } 47 48 func Test_mrUnapprove(t *testing.T) { 49 repo := copyTestRepo(t) 50 orig := exec.Command(labBinaryPath, "mr", "unapprove", "18") 51 orig.Dir = repo 52 53 b, err := orig.CombinedOutput() 54 if err != nil { 55 t.Log(string(b)) 56 t.Error(err) 57 } 58 59 origOutput := string(b) 60 origOutput = stripansi.Strip(origOutput) 61 62 require.Contains(t, origOutput, `Merge Request !18 unapproved`) 63 }