github.com/zaquestion/lab@v0.25.1/cmd/mr_subscribe_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_mrSubscribeSetup(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, `Subscribed: No`) 29 } 30 31 func Test_mrSubscribe(t *testing.T) { 32 repo := copyTestRepo(t) 33 orig := exec.Command(labBinaryPath, "mr", "subscribe", "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, `Subscribed to merge request !18`) 46 } 47 48 func Test_mrUnsubscribe(t *testing.T) { 49 repo := copyTestRepo(t) 50 orig := exec.Command(labBinaryPath, "mr", "unsubscribe", "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, `Unsubscribed from merge request !18`) 63 }