30 lines
781 B
Go
30 lines
781 B
Go
package gitea_test
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/golangci/golangci-lint/pkg/report"
|
|
"github.com/stretchr/testify/mock"
|
|
|
|
"code.icb4dc0.de/prskr/nitter/nitters/gitea"
|
|
"code.icb4dc0.de/prskr/nitter/nitters/gitea/mocks"
|
|
)
|
|
|
|
func Test_PRNitter_Report_MockCreatorError_Error(t *testing.T) {
|
|
expectedError := errors.New("error")
|
|
creator := mocks.NewPullReviewCreator(t)
|
|
creator.
|
|
EXPECT().
|
|
CreatePullReview(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
|
|
Return(nil, nil, expectedError).
|
|
Times(1)
|
|
|
|
p := gitea.NewPRNitter(creator, &gitea.GiteaPRConfig{})
|
|
|
|
if err := p.Report(new(report.Data), nil); err == nil {
|
|
t.Error("expected error bot got none")
|
|
} else if !errors.Is(err, expectedError) {
|
|
t.Errorf("Error %v was not expected", err)
|
|
}
|
|
}
|