Skip to content

Commit f5951aa

Browse files
authored
Merge pull request #597 from zaquestion/fix_note_tests
fix: (mr_note) move tests to new dumping ground
2 parents f551b39 + 6a99151 commit f5951aa

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

cmd/mr_discussion_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
func Test_mrCreateDiscussion(t *testing.T) {
1414
repo := copyTestRepo(t)
15-
cmd := exec.Command(labBinaryPath, "mr", "discussion", "lab-testing", "1",
15+
cmd := exec.Command(labBinaryPath, "mr", "discussion", "lab-testing", mrCommentSlashDiscussionDumpsterID,
1616
"-m", "discussion text")
1717
cmd.Dir = repo
1818

@@ -22,7 +22,7 @@ func Test_mrCreateDiscussion(t *testing.T) {
2222
t.Fatal(err)
2323
}
2424

25-
require.Contains(t, string(b), "https://gitlab.com/lab-testing/test/merge_requests/1#note_")
25+
require.Contains(t, string(b), "https://gitlab.com/lab-testing/test/merge_requests/"+mrCommentSlashDiscussionDumpsterID+"#note_")
2626
}
2727

2828
func Test_mrCreateDiscussion_file(t *testing.T) {
@@ -33,7 +33,7 @@ func Test_mrCreateDiscussion_file(t *testing.T) {
3333
t.Fatal(err)
3434
}
3535

36-
cmd := exec.Command(labBinaryPath, "mr", "discussion", "lab-testing", "1",
36+
cmd := exec.Command(labBinaryPath, "mr", "discussion", "lab-testing", mrCommentSlashDiscussionDumpsterID,
3737
"-F", "hellolab.txt")
3838
cmd.Dir = repo
3939

@@ -43,7 +43,7 @@ func Test_mrCreateDiscussion_file(t *testing.T) {
4343
t.Fatal(err)
4444
}
4545

46-
require.Contains(t, string(b), "https://gitlab.com/lab-testing/test/merge_requests/1#note_")
46+
require.Contains(t, string(b), "https://gitlab.com/lab-testing/test/merge_requests/"+mrCommentSlashDiscussionDumpsterID+"#note_")
4747
}
4848

4949
func Test_mrDiscussionMsg(t *testing.T) {

cmd/mr_note_test.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import (
1111
"github.com/stretchr/testify/require"
1212
)
1313

14+
// #3952 is not special, it's just a place to dump discussions as mr #1 filled up, long term should update the tests clean up what they create
15+
const mrCommentSlashDiscussionDumpsterID = "3952"
16+
1417
func Test_mrCreateNote(t *testing.T) {
1518
tests := []struct {
1619
Name string
@@ -19,16 +22,16 @@ func Test_mrCreateNote(t *testing.T) {
1922
}{
2023
{
2124
Name: "Normal text",
22-
Args: []string{"lab-testing", "1", "-m", "note text"},
23-
ExpectedBody: "https://gitlab.com/lab-testing/test/merge_requests/1#note_",
25+
Args: []string{"lab-testing", mrCommentSlashDiscussionDumpsterID, "-m", "note text"},
26+
ExpectedBody: "https://gitlab.com/lab-testing/test/merge_requests/" + mrCommentSlashDiscussionDumpsterID + "#note_",
2427
},
2528
{
2629
// Escaped sequence text direct in the argument list as the
2730
// following one was already a problem:
2831
// https://github.com/zaquestion/lab/issues/376
2932
Name: "Escape char",
30-
Args: []string{"lab-testing", "1", "-m", "{\"key\": \"value\"}"},
31-
ExpectedBody: "https://gitlab.com/lab-testing/test/merge_requests/1#note_",
33+
Args: []string{"lab-testing", mrCommentSlashDiscussionDumpsterID, "-m", "{\"key\": \"value\"}"},
34+
ExpectedBody: "https://gitlab.com/lab-testing/test/merge_requests/" + mrCommentSlashDiscussionDumpsterID + "#note_",
3235
},
3336
}
3437
noteCmd := []string{"mr", "note"}
@@ -58,7 +61,7 @@ func Test_mrCreateNote_file(t *testing.T) {
5861
t.Fatal(err)
5962
}
6063

61-
cmd := exec.Command(labBinaryPath, "mr", "note", "lab-testing", "1",
64+
cmd := exec.Command(labBinaryPath, "mr", "note", "lab-testing", mrCommentSlashDiscussionDumpsterID,
6265
"-F", "hellolab.txt")
6366
cmd.Dir = repo
6467

@@ -68,13 +71,13 @@ func Test_mrCreateNote_file(t *testing.T) {
6871
t.Fatal(err)
6972
}
7073

71-
require.Contains(t, string(b), "https://gitlab.com/lab-testing/test/merge_requests/1#note_")
74+
require.Contains(t, string(b), "https://gitlab.com/lab-testing/test/merge_requests/"+mrCommentSlashDiscussionDumpsterID+"#note_")
7275
}
7376

7477
func Test_mrReplyAndResolve(t *testing.T) {
7578
repo := copyTestRepo(t)
7679

77-
cmd := exec.Command(labBinaryPath, "mr", "note", "lab-testing", "1", "-m", "merge request text")
80+
cmd := exec.Command(labBinaryPath, "mr", "note", "lab-testing", mrCommentSlashDiscussionDumpsterID, "-m", "merge request text")
7881
cmd.Dir = repo
7982

8083
a, err := cmd.CombinedOutput()
@@ -87,7 +90,7 @@ func Test_mrReplyAndResolve(t *testing.T) {
8790
noteID := noteIDs[1]
8891

8992
// add reply to the noteID
90-
reply := exec.Command(labBinaryPath, "mr", "reply", "lab-testing", "1:"+noteID, "-m", "reply to note")
93+
reply := exec.Command(labBinaryPath, "mr", "reply", "lab-testing", mrCommentSlashDiscussionDumpsterID+":"+noteID, "-m", "reply to note")
9194
reply.Dir = repo
9295
c, err := reply.CombinedOutput()
9396
if err != nil {
@@ -98,15 +101,15 @@ func Test_mrReplyAndResolve(t *testing.T) {
98101
replyIDs := strings.Split(_replyIDs[0], "#note_")
99102
replyID := replyIDs[1]
100103

101-
show := exec.Command(labBinaryPath, "mr", "show", "lab-testing", "1", "--comments")
104+
show := exec.Command(labBinaryPath, "mr", "show", "lab-testing", mrCommentSlashDiscussionDumpsterID, "--comments")
102105
show.Dir = repo
103106
d, err := show.CombinedOutput()
104107
if err != nil {
105108
t.Log(string(d))
106109
t.Fatal(err)
107110
}
108111

109-
resolve := exec.Command(labBinaryPath, "mr", "resolve", "lab-testing", "1:"+noteID)
112+
resolve := exec.Command(labBinaryPath, "mr", "resolve", "lab-testing", mrCommentSlashDiscussionDumpsterID+":"+noteID)
110113
resolve.Dir = repo
111114
e, err := resolve.CombinedOutput()
112115
if err != nil {

0 commit comments

Comments
 (0)