github.com/nkprince007/lab@v0.6.2-0.20171218071646-19d68b56f403/cmd/mrCreate_test.go (about) 1 package cmd 2 3 import ( 4 "os/exec" 5 "testing" 6 7 "github.com/stretchr/testify/require" 8 ) 9 10 func Test_mrCreate(t *testing.T) { 11 repo := copyTestRepo(t) 12 13 git := exec.Command("git", "checkout", "mrtest") 14 git.Dir = repo 15 out, err := git.CombinedOutput() 16 if err != nil { 17 t.Log(string(out)) 18 t.Fatal(err) 19 } 20 21 cmd := exec.Command("../lab_bin", "mr", "create", "lab-testing", 22 "-m", "mr title") 23 cmd.Dir = repo 24 25 b, _ := cmd.CombinedOutput() 26 t.Log(string(b)) 27 // This message indicates that the GitLab API tried to create the MR, 28 // its good enough to assert lab is working 29 require.Contains(t, string(b), "409 {message: [Cannot Create: This merge request already exists: [\"mr title\"]]}") 30 } 31 32 func Test_mrText(t *testing.T) { 33 text, err := mrText("master", "mrtest", "lab-testing", "origin") 34 if err != nil { 35 t.Log(text) 36 t.Fatal(err) 37 } 38 require.Contains(t, text, `Added additional commit for LastCommitMessage and meeting requirements for Log test (>1 commit) 39 40 I am the mr tmpl 41 # Requesting a merge into origin:master from lab-testing:mrtest 42 # 43 # Write a message for this merge request. The first block 44 # of text is the title and the rest is the description. 45 # 46 # Changes: 47 # 48 # 54fd49a (Zaq? Wiedmann`) 49 50 }