|
|
|
@ -42,12 +42,12 @@ func TestHandleMessageNotOnion(t *testing.T) {
|
|
|
|
|
SetArg(1, messaging.URLFoundMsg{URL: "https://example.org"}).
|
|
|
|
|
Return(nil)
|
|
|
|
|
|
|
|
|
|
if err := handleMessage(apiClientMock, -1)(subscriberMock, &msg); err == nil {
|
|
|
|
|
if err := handleMessage(apiClientMock, -1, []string{})(subscriberMock, &msg); err == nil {
|
|
|
|
|
t.FailNow()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestHandleMessageNoSchedule(t *testing.T) {
|
|
|
|
|
func TestHandleMessageAlreadyCrawled(t *testing.T) {
|
|
|
|
|
mockCtrl := gomock.NewController(t)
|
|
|
|
|
defer mockCtrl.Finish()
|
|
|
|
|
|
|
|
|
@ -64,7 +64,25 @@ func TestHandleMessageNoSchedule(t *testing.T) {
|
|
|
|
|
SearchResources("https://example.onion", "", time.Time{}, time.Time{}, 1, 1).
|
|
|
|
|
Return([]api.ResourceDto{}, int64(1), nil)
|
|
|
|
|
|
|
|
|
|
if err := handleMessage(apiClientMock, -1)(subscriberMock, &msg); err != nil {
|
|
|
|
|
if err := handleMessage(apiClientMock, -1, []string{"png"})(subscriberMock, &msg); err != nil {
|
|
|
|
|
t.FailNow()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestHandleMessageForbiddenExtensions(t *testing.T) {
|
|
|
|
|
mockCtrl := gomock.NewController(t)
|
|
|
|
|
defer mockCtrl.Finish()
|
|
|
|
|
|
|
|
|
|
apiClientMock := api_mock.NewMockClient(mockCtrl)
|
|
|
|
|
subscriberMock := messaging_mock.NewMockSubscriber(mockCtrl)
|
|
|
|
|
|
|
|
|
|
msg := nats.Msg{}
|
|
|
|
|
subscriberMock.EXPECT().
|
|
|
|
|
ReadMsg(&msg, &messaging.URLFoundMsg{}).
|
|
|
|
|
SetArg(1, messaging.URLFoundMsg{URL: "https://example.onion/image.png"}).
|
|
|
|
|
Return(nil)
|
|
|
|
|
|
|
|
|
|
if err := handleMessage(apiClientMock, -1, []string{"png"})(subscriberMock, &msg); err == nil {
|
|
|
|
|
t.FailNow()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -90,7 +108,7 @@ func TestHandleMessage(t *testing.T) {
|
|
|
|
|
PublishMsg(&messaging.URLTodoMsg{URL: "https://example.onion"}).
|
|
|
|
|
Return(nil)
|
|
|
|
|
|
|
|
|
|
if err := handleMessage(apiClientMock, -1)(subscriberMock, &msg); err != nil {
|
|
|
|
|
if err := handleMessage(apiClientMock, -1, []string{})(subscriberMock, &msg); err != nil {
|
|
|
|
|
t.FailNow()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|