This commit is contained in:
@@ -65,12 +65,12 @@ func (s SendReq) ToEMail() email.Mail {
|
||||
|
||||
// MockInvoiceService mocks the invoice.Service interface
|
||||
type MockInvoiceService struct {
|
||||
GenerateFunc func(creditor model.Entity, debtor *model.Entity, durationThreshold time.Duration, hourlyRate float64, repos []invoice.Repo) (io.ReadCloser, *report.Report, error)
|
||||
GenerateFunc func(creditor model.Entity, debtor *model.Entity, hourlyRate float64, repos []invoice.Repo, opts *invoice.Options) (io.ReadCloser, *report.Report, error)
|
||||
}
|
||||
|
||||
func (m *MockInvoiceService) Generate(creditor model.Entity, debtor *model.Entity, durationThreshold time.Duration, hourlyRate float64, repos []invoice.Repo) (io.ReadCloser, *report.Report, error) {
|
||||
func (m *MockInvoiceService) Generate(creditor model.Entity, debtor *model.Entity, hourlyRate float64, repos []invoice.Repo, opts *invoice.Options) (io.ReadCloser, *report.Report, error) {
|
||||
if m.GenerateFunc != nil {
|
||||
return m.GenerateFunc(creditor, debtor, durationThreshold, hourlyRate, repos)
|
||||
return m.GenerateFunc(creditor, debtor, hourlyRate, repos, opts)
|
||||
}
|
||||
return nil, &report.Report{}, nil
|
||||
}
|
||||
@@ -166,7 +166,12 @@ func TestCreateInvoice(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mockInvoiceService := &MockInvoiceService{
|
||||
GenerateFunc: tt.mockGenerate,
|
||||
GenerateFunc: func(creditor model.Entity, debtor *model.Entity, hourlyRate float64, repos []invoice.Repo, opts *invoice.Options) (io.ReadCloser, *report.Report, error) {
|
||||
if opts == nil {
|
||||
opts = &invoice.DefaultOptions
|
||||
}
|
||||
return tt.mockGenerate(creditor, debtor, opts.Mindur, hourlyRate, repos)
|
||||
},
|
||||
}
|
||||
service := Service{invoice: mockInvoiceService, log: dummyLogger} // Pass the dummy logger
|
||||
|
||||
@@ -298,7 +303,12 @@ func TestSendInvoice(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mockInvoiceService := &MockInvoiceService{
|
||||
GenerateFunc: tt.mockGenerate,
|
||||
GenerateFunc: func(creditor model.Entity, debtor *model.Entity, hourlyRate float64, repos []invoice.Repo, opts *invoice.Options) (io.ReadCloser, *report.Report, error) {
|
||||
if opts == nil {
|
||||
opts = &invoice.DefaultOptions
|
||||
}
|
||||
return tt.mockGenerate(creditor, debtor, opts.Mindur, hourlyRate, repos)
|
||||
},
|
||||
}
|
||||
mockEmailService := &MockEmailService{
|
||||
SendFunc: tt.mockSend,
|
||||
|
||||
Reference in New Issue
Block a user