@@ -8,9 +8,10 @@ import (
8
8
"github.com/google/go-github/v55/github"
9
9
"github.com/jinzhu/copier"
10
10
"github.com/stretchr/testify/assert"
11
+ "github.com/stretchr/testify/require"
11
12
)
12
13
13
- var testBot * Bot = & Bot {
14
+ var testBot = & Bot {
14
15
ctx : context .Background (),
15
16
issueClient : & testClient {},
16
17
}
@@ -50,7 +51,7 @@ func TestHandleEvent(t *testing.T) {
50
51
}
51
52
testEventCopy .IssueCommentEvent .Comment .Body = github .String ("/assign" )
52
53
res , err := testBot .HandleEvent (ctx , testEventCopy )
53
- assert .NoError (t , err )
54
+ require .NoError (t , err )
54
55
assert .NotEmpty (t , res )
55
56
})
56
57
@@ -67,7 +68,7 @@ func TestHandleEvent(t *testing.T) {
67
68
}
68
69
testEventCopy .IssueCommentEvent .Comment .Body = github .String ("/assign \r \n test body" )
69
70
res , err := testBot .HandleEvent (ctx , testEventCopy )
70
- assert .NoError (t , err )
71
+ require .NoError (t , err )
71
72
assert .NotEmpty (t , res )
72
73
})
73
74
@@ -84,7 +85,7 @@ func TestHandleEvent(t *testing.T) {
84
85
}
85
86
testEventCopy .IssueCommentEvent .Comment .Body = github .String ("/assign" )
86
87
res , err := testBot .HandleEvent (ctx , testEventCopy )
87
- assert .Error (t , err )
88
+ require .Error (t , err )
88
89
assert .NotEmpty (t , res )
89
90
})
90
91
@@ -99,7 +100,7 @@ func TestHandleEvent(t *testing.T) {
99
100
}
100
101
testEventCopy .IssueCommentEvent .Comment .Body = github .String ("assign" )
101
102
res , err := testBot .HandleEvent (ctx , testEventCopy )
102
- assert .NoError (t , err )
103
+ require .NoError (t , err )
103
104
assert .Equal (t , "no command found" , res )
104
105
})
105
106
}
@@ -111,7 +112,7 @@ func TestCreateIssueComment(t *testing.T) {
111
112
}
112
113
testBot .issueClient = & tc
113
114
err := testBot .CreateIssueComment ("test" , testEvent )
114
- assert .Error (t , err )
115
+ require .Error (t , err )
115
116
})
116
117
117
118
t .Run ("create issue comment" , func (t * testing.T ) {
@@ -120,7 +121,7 @@ func TestCreateIssueComment(t *testing.T) {
120
121
}
121
122
testBot .issueClient = & tc
122
123
err := testBot .CreateIssueComment ("test" , testEvent )
123
- assert .NoError (t , err )
124
+ require .NoError (t , err )
124
125
})
125
126
126
127
t .Run ("create issue comment with empty body" , func (t * testing.T ) {
@@ -129,7 +130,7 @@ func TestCreateIssueComment(t *testing.T) {
129
130
}
130
131
testBot .issueClient = & tc
131
132
err := testBot .CreateIssueComment ("" , testEvent )
132
- assert .Error (t , err )
133
+ require .Error (t , err )
133
134
})
134
135
}
135
136
@@ -140,7 +141,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
140
141
}
141
142
testBot .issueClient = & tc
142
143
assignee , err := testBot .AssignIssueToCommenter (testEvent )
143
- assert .Error (t , err )
144
+ require .Error (t , err )
144
145
assert .Empty (t , assignee )
145
146
})
146
147
@@ -156,7 +157,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
156
157
}
157
158
testEventCopy .IssueCommentEvent .Issue .Assignees = []* github.User {}
158
159
assignee , err := testBot .AssignIssueToCommenter (testEventCopy )
159
- assert .NoError (t , err )
160
+ require .NoError (t , err )
160
161
assert .Equal (t , "testCommentLogin" , assignee )
161
162
})
162
163
@@ -170,7 +171,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
170
171
}
171
172
testEventCopy .IssueCommentEvent .Issue .State = github .String ("closed" )
172
173
assignee , err := testBot .AssignIssueToCommenter (testEventCopy )
173
- assert .Error (t , err )
174
+ require .Error (t , err )
174
175
assert .Empty (t , assignee )
175
176
})
176
177
@@ -184,7 +185,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
184
185
}
185
186
testEventCopy .IssueCommentEvent .Issue .Assignees = []* github.User {{Login : github .String ("testCommentLogin" )}}
186
187
assignee , err := testBot .AssignIssueToCommenter (testEventCopy )
187
- assert .Error (t , err )
188
+ require .Error (t , err )
188
189
assert .Empty (t , assignee )
189
190
})
190
191
@@ -200,7 +201,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
200
201
}
201
202
testEventCopy .IssueCommentEvent .Issue .Assignees = []* github.User {{Login : github .String ("testCommentLogin2" )}}
202
203
assignee , err := testBot .AssignIssueToCommenter (testEventCopy )
203
- assert .Error (t , err )
204
+ require .Error (t , err )
204
205
assert .Empty (t , assignee )
205
206
})
206
207
}
0 commit comments