forked from zaquestion/lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmr_show_test.go
75 lines (60 loc) · 1.65 KB
/
mr_show_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package cmd
import (
"os/exec"
"testing"
"github.com/acarl005/stripansi"
"github.com/stretchr/testify/require"
)
func Test_mrShow(t *testing.T) {
t.Parallel()
repo := copyTestRepo(t)
// a comment has been added to
// https://gitlab.com/zaquestion/test/-/merge_requests/1 for this test
cmd := exec.Command(labBinaryPath, "mr", "show", "1", "--comments")
cmd.Dir = repo
b, err := cmd.CombinedOutput()
if err != nil {
t.Log(string(b))
t.Error(err)
}
out := string(b)
out = stripansi.Strip(out)
require.Contains(t, out, `
#1 Test MR for lab list
===================================
This MR is to remain open for testing the lab mr list functionality
-----------------------------------
Project: zaquestion/test
Branches: mrtest->master
Status: Open
Assignee: zaquestion
Author: zaquestion
Milestone: 1.0
Labels: documentation
WebURL: https://gitlab.com/zaquestion/test/-/merge_requests/1
`)
require.Contains(t, string(b), `commented at`)
require.Contains(t, string(b), `updated comment at`)
}
func Test_mrShow_patch(t *testing.T) {
t.Parallel()
repo := copyTestRepo(t)
cmd := exec.Command(labBinaryPath, "mr", "show", "origin", "1", "--patch")
cmd.Dir = repo
b, err := cmd.CombinedOutput()
if err != nil {
t.Log(string(b))
t.Error(err)
}
out := string(b)
out = stripansi.Strip(out)
// The index line below has been stripped as it is dependent on
// the git version and pretty defaults.
require.Contains(t, out, `commit 54fd49a2ac60aeeef5ddc75efecd49f85f7ba9b0
Author: Zaq? Wiedmann <[email protected]>
Date: Tue Sep 19 03:55:16 2017 +0000
Test file for MR test
diff --git a/mrtest b/mrtest
new file mode 100644
`)
}