@@ -88,48 +88,54 @@ func TestNoteRegex(t *testing.T) {
8888}
8989
9090func TestRun (t * testing.T ) {
91+ stubPRBody := func (body string ) func (owner , repo string , num int ) (string , error ) {
92+ return func (owner , repo string , num int ) (string , error ) {
93+ return body , nil
94+ }
95+ }
96+
9197 testcases := []struct {
9298 cmd * Command
9399 input * github.PullRequest
94100 expected string
95101 }{
96102 {
97- cmd : & Command {requireAny : true , labels : []string {"v1" }},
103+ cmd : & Command {requireAny : true , labels : []string {"v1" }, noteRegex : defaultNoteRegex , getPullRequestBody : stubPRBody ( "" ) },
98104 input : & github.PullRequest {Labels : []* github.Label {& github.Label {Name : github .String ("v1" )}}},
99105 expected : "" ,
100106 },
101107 {
102- cmd : & Command {requireAny : true , labels : []string {"v2" }},
108+ cmd : & Command {requireAny : true , labels : []string {"v2" }, noteRegex : defaultNoteRegex , getPullRequestBody : stubPRBody ( "" ) },
103109 input : & github.PullRequest {Labels : []* github.Label {& github.Label {Name : github .String ("v1" )}}},
104110 expected : "1 check(s) failed:\n * missing label: v2" ,
105111 },
106112 {
107- cmd : & Command {requireAny : true , labels : []string {"v2" , "v3" }},
113+ cmd : & Command {requireAny : true , labels : []string {"v2" , "v3" }, noteRegex : defaultNoteRegex , getPullRequestBody : stubPRBody ( "" ) },
108114 input : & github.PullRequest {Labels : []* github.Label {& github.Label {Name : github .String ("v1" )}}},
109115 expected : "2 check(s) failed:\n * missing label: v2\n * missing label: v3" ,
110116 },
111117 {
112- cmd : & Command {requireAny : true , milestone : "v1" },
118+ cmd : & Command {requireAny : true , milestone : "v1" , noteRegex : defaultNoteRegex , getPullRequestBody : stubPRBody ( "" ) },
113119 input : & github.PullRequest {Milestone : & github.Milestone {Title : github .String ("v1" )}},
114120 expected : "" ,
115121 },
116122 {
117- cmd : & Command {requireAny : true , anyMilestone : true },
123+ cmd : & Command {requireAny : true , anyMilestone : true , noteRegex : defaultNoteRegex , getPullRequestBody : stubPRBody ( "" ) },
118124 input : & github.PullRequest {Milestone : & github.Milestone {Title : github .String ("v1" )}},
119125 expected : "" ,
120126 },
121127 {
122- cmd : & Command {requireAny : true , milestone : "v2" },
128+ cmd : & Command {requireAny : true , milestone : "v2" , noteRegex : defaultNoteRegex , getPullRequestBody : stubPRBody ( "" ) },
123129 input : & github.PullRequest {Milestone : & github.Milestone {Title : github .String ("v1" )}},
124130 expected : "1 check(s) failed:\n * unexpected milestone: expected \" v2\" , got \" v1\" " ,
125131 },
126132 {
127- cmd : & Command {requireAny : true , anyMilestone : true },
133+ cmd : & Command {requireAny : true , anyMilestone : true , noteRegex : defaultNoteRegex , getPullRequestBody : stubPRBody ( "" ) },
128134 input : & github.PullRequest {},
129135 expected : "1 check(s) failed:\n * missing milestone" ,
130136 },
131137 {
132- cmd : & Command {requireAny : true , labels : []string {"v2" , "v3" }},
138+ cmd : & Command {requireAny : true , labels : []string {"v2" , "v3" }, noteRegex : defaultNoteRegex , getPullRequestBody : stubPRBody ( "" ) },
133139 input : & github.PullRequest {
134140 Labels : []* github.Label {
135141 & github.Label {Name : github .String ("v2" )},
@@ -139,7 +145,7 @@ func TestRun(t *testing.T) {
139145 expected : "" ,
140146 },
141147 {
142- cmd : & Command {requireAll : true , labels : []string {"v2" , "v3" }},
148+ cmd : & Command {requireAll : true , labels : []string {"v2" , "v3" }, noteRegex : defaultNoteRegex , getPullRequestBody : stubPRBody ( "" ) },
143149 input : & github.PullRequest {
144150 Labels : []* github.Label {
145151 & github.Label {Name : github .String ("v2" )},
@@ -153,7 +159,7 @@ func TestRun(t *testing.T) {
153159 for i := range testcases {
154160 tc := testcases [i ]
155161
156- err := tc .cmd .HandlePullRequest ("" , "" , tc .input )
162+ err := tc .cmd .HandlePullRequest ("myuser " , "myrepo " , tc .input )
157163
158164 if tc .expected != "" && ! strings .Contains (err .Error (), tc .expected ) {
159165 t .Errorf ("unexpected error: expected=%q, got=%q" , tc .expected , err )
0 commit comments